Extracting features with CNN VGG16 and KNN classification

6 ビュー (過去 30 日間)
Andrea Magni
Andrea Magni 2018 年 8 月 24 日
編集済み: Andrea Magni 2018 年 8 月 24 日
Hi, I'm new to machine learning and classification. I read a lot of documentation in matlab in order to create a function that calculates the features of a given dataset. This is what I wrote:
tic;
net = vgg16;
layer = 'fc7';
net_size = net.Layers(1).InputSize;
[images, labels] = readlists();
n = numel(images);
f = [];
for i = 1 : n
im = imread(['simplicity/' images{i}]);
im = imresize(im, net_size(1:2));
f = [f; activations(net, im, layer, 'ExecutionEnvironment', 'gpu')];
end
toc;
save('f', 'f');
Is this correct or did I calculated something useless? However I've tested it and the accuracy of training is: 95% and test: 94% using a dataset of 1000 images.
Now I want to know if I'm doing it right. How can I get the corresponding label to an image? I mean, if I want to know the corresponding label, given an image (for example food) of the dataset, how can I do that?
By the way, readList() returns a cell array filled with the name of each image (images) and the corresponding labels (labels).
It takes about ~30 secs to calculate 'f' using gpu.

回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by