Testing Accuracy for Test Dataset

8 次查看(过去 30 天)
Nitish Singla
Nitish Singla 2021-7-8
回答: Rahul 2024-10-18
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.

回答(1 个)

Rahul
Rahul 2024-10-18
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:
Hope this helps! Thanks.

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by