Testing Accuracy for Test Dataset
8 views (last 30 days)
Show older comments
How to find testing accuracy for a whole testing dataset of a deep neural network ? Like we use model.evaluate in python, what to use in MATLAB. I have a testing dataset in a folder with 5 categories and images in it.
outputFolder = fullfile('E:\Cifar5categories');
rootFolder = fullfile(outputFolder, 'test');
categories = {'automobile', 'cat', 'dog', 'truck', };
imds = imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
trainedNetwork_1 is the trained network, trained using Deep Learning Designer. Please tell me the command.
0 Comments
Answers (1)
Rahul
on 18 Oct 2024
I understand that you have a trained network 'trainedNetwork_1', trained using 'Deep Network Designer' and now you require to test its accuracy on the testing dataset.
You can achieve the desired result by using the 'classify' function which takes the trained network and 'imageDatastore' as inputs to obtain the predicted results. Here is an example:
predictedLabels = classify(trainedNetwork_1, imds);
% Here 'trainedNetwork_1' would be the trained network as mentioned
% Here 'imds' would be the 'imageDatastore' of the testing images
Further, you can obtain the accuracy by comparing the predicted labels with the true labels like this:
trueLabels = imds.Labels;
accuracy = mean(predictedLabels == trueLabels);
You can refer to the following MathWorks documentations:
'classify': https://www.mathworks.com/help/releases/R2021a/deeplearning/ref/seriesnetwork.classify.html
Hope this helps! Thanks.
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!