Error in testing accuracy code

% Load the pre-trained network (if you already trained and saved the network)
net = load('net.mat');
Error using load
Unable to find file or directory 'net.mat'.
% Load the test dataset
testDir = 'path_dir'; % Directory containing test images
imdsTest = imageDatastore(testDir, 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
% Resize the images to match the network input layer.
augimdsTest = augmentedImageDatastore([224 224 3], imdsTest);
% Classify the test images using the trained network
YPredTest = classify(net, augimdsTest);
% Get the ground truth labels for the test images
YTest = imdsTest.Labels;
% Calculate the test accuracy
testAccuracy = mean(YPredTest == YTest);
the error the code shows is that the classify has 3 arguments i am not able to understand please can u help

3 件のコメント

Image Analyst
Image Analyst 2023 年 7 月 29 日
Looks like it should work.
Y = classify(net,images) predicts the class labels of the specified images using the trained network net.
where "images" is an image datastore.
What does this show in the command window:
whos augimdsTest
Does it look normal or is it null or has a size or zero or somehow look weird?
Darshana
Darshana 2023 年 7 月 29 日
thank you
Image Analyst
Image Analyst 2023 年 7 月 29 日
That was not an answer to my question. Anyway Walter discovered the true reason - did you see his answer below? He's basically saying to do this:
% Load variables in the file into a structure variable.
storedStructure = load('net.mat');
% Get the one network variable we need from the structure into its own variable.
net = storedStructure.net;

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 7 月 29 日

1 投票

The output of load applied to a mat file, is a struct that has one field for each variable loaded. So you would need net.net where the first net is the struct returned from load and the second is the variable loaded.

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2023 年 7 月 29 日

コメント済み:

2023 年 7 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by