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