Extracting features from pretrained network and feed them into a softmax layer for calssification
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I use ResNet50 to extract features from images then I want to feed these features into softmax layer for classification but I don't know how to feed these features into softmax layer. I used fitcecoc for classification but it didn't give me the good results for that reason I want to use softmax layer rather than fitcecoc.
Here is my code:
imds = imageDatastore('chromosomes','IncludeSubfolders',true,'LabelSource','foldernames');
[trainingSet,testSet] = splitEachLabel(imds,0.8, 'randomize');
net = resnet50 ();
imageSize = net.Layers(1).InputSize;
augmentedTrainingSet = augmentedImageDatastore(imageSize, trainingSet,'ColorPreprocessing','gray2rgb');
augmentedTestSet = augmentedImageDatastore(imageSize, testSet,'ColorPreprocessing','gray2rgb');
featureLayer = 'activation_43_relu';
trainingFeatures = activations(net, augmentedTrainingSet, featureLayer, 'OutputAs','rows');
testFeatures = activations(net, augmentedTestSet, featureLayer,'OutputAs','rows');
trainingLabels = trainingSet.Labels;
testLabels = testSet.Labels;
classifier = fitcecoc(trainingFeatures,trainingLabels);
YPred = predict(classifier,testFeatures);
accuracy = mean(YPred == testLabels)
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!