我们可以从Alexnet提取fc8图层特征吗

时间:2019-02-26 08:38:58

标签: deep-learning conv-neural-network

我是深度学习的新手。我正在使用下面链接中给出的代码从Alexnet中提取功能。

`
unzip('MerchData.zip');
images = imageDatastore('MerchData',...
    'IncludeSubfolders',true,...
    'LabelSource','foldernames');

[trainingImages,testImages] = splitEachLabel(images,0.7,'randomized');


numTrainImages = numel(trainingImages.Labels);
idx = randperm(numTrainImages,16);
figure
for i = 1:16
    subplot(4,4,i)
    I = readimage(trainingImages,idx(i));
    imshow(I)
end

%% Load Pretrained Network

net = alexnet;
net.Layers



%% Extract Image Features

layer = 'fc7';
trainingFeatures = activations(net,trainingImages,layer);
testFeatures = activations(net,testImages,layer);

    %%
    % Extract the class labels from the training and test data.
    trainingLabels = trainingImages.Labels;
    testLabels = testImages.Labels;

    %% Fit Image Classifier

    classifier = fitcecoc(trainingFeatures,trainingLabels);

    %% Classify Test Images
   predictedLabels = predict(classifier,testFeatures);

   % Calculate the classification accuracy on the test set. Accuracy is the
    % fraction of labels that the network predicts correctly.
    accuracy = mean(predictedLabels == testLabels)

我在上面的代码中使用FC8层代替了fc7,我得到的输出是samples * 1000 data。我将它们用作分类的功能,并获得了准确性等结果。

另一点是AlexNet中的“ fc8”层是不能用于特征提取的分类层。

哪个概念是正确的。如果这些不是功能,您能否说明出样本* 1000的数据类型。

0 个答案:

没有答案
相关问题