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 Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by