how can I extract predicted label and testlabel from already trained deep learning model. the code below gives error while running
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
load('MyVGG19Model.mat');
imdsTest = imageDatastore("C:\Users\Bashir\Desktop\Training dataset\Test set", ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
imageAugmenter = imageDataAugmenter( ...
'RandRotation',[-90,90], ...
'RandScale',[1 1.1], ...
'RandXTranslation',[-3 3], ...
'RandYTranslation',[-3 3]);
imageSize = myvgg16.Layers(1).InputSize;
augmentedTestSet = augmentedImageDatastore(imageSize, imdsTest, 'DataAugmentation',imageAugmenter);
predictedLabels = predict(myvgg16, augmentedTestSet);
testLabels = imdsTest.Labels
% Tabulate the results using a confusion matrix.
confMat = confusionmat(testLabels, predictedLabels);
% Convert confusion matrix into percentage form
confMat = bsxfun(@rdivide,confMat,sum(confMat,2))
7 comentarios
Walter Roberson
el 4 de Dic. de 2021
You could try
categorical(string(round(predictedLabels)))
but I would recommend looking more carefully at the values in predictedLabels. The values of the predictedLabels might possibly be class numbers, in which case you would want to use them to index the categories that were used in TestLabels .
Respuestas (1)
yanqi liu
el 4 de Dic. de 2021
load('MyVGG19Model.mat');
imdsTest = imageDatastore("C:\Users\Bashir\Desktop\Training dataset\Test set", ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
imageAugmenter = imageDataAugmenter( ...
'RandRotation',[-90,90], ...
'RandScale',[1 1.1], ...
'RandXTranslation',[-3 3], ...
'RandYTranslation',[-3 3]);
imageSize = myvgg16.Layers(1).InputSize;
augmentedTestSet = augmentedImageDatastore(imageSize, imdsTest, 'DataAugmentation',imageAugmenter);
predictedLabels = predict(myvgg16, augmentedTestSet);
testLabels = imdsTest.Labels
% Tabulate the results using a confusion matrix.
confMat = confusionmat(double(testLabels), double(predictedLabels));
% Convert confusion matrix into percentage form
confMat = bsxfun(@rdivide,confMat,sum(confMat,2))
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!