Extracting features with CNN VGG16 and KNN classification

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by