how to force to use the Classify from the neural net toolbox?

how to force to use the Classify from the neural net toolbox? I am using transfer learning to train my images using alexnet. when I use classify it gives me following error:- Error using classify (line 123) Requires at least three arguments. When I look at classify in the help is pulling it from the Statistics and Machine learning toolbox. Do you know how to force to use the Classify from the neural net toolbox?
clear all;
close all;
clc;
testFolder = 'Test';
%creates imageDataStore object
testImages = imageDatastore(testFolder,'FileExtensions',{'.jpg','.tif'});
testImages.ReadFcn = @readImageFunction;%read images and resize it to the required size for the alex net
myNet = matfile('myNet.mat');%load the pre-trained net
predictedLabels = classify(myNet, testImages);
accuracy = mean(predictedLabels == testImages.Labels);

 Accepted Answer

testFolder = 'Test';
%creates imageDataStore object
testImages = imageDatastore(testFolder,'FileExtensions',{'.jpg','.tif'});
testImages.ReadFcn = @readImageFunction;%read images and resize it to the required size for the alex net
matobj = matfile('myNet.mat');%load the pre-trained net
predictedLabels = classify(matobj.myNet, testImages);
accuracy = mean(predictedLabels == testImages.Labels);

3 Comments

What is .myNet that you added? Is it the name of mat file? if it is, I tried the same but ended up with an error- Reference to the non-existent field 'Nameoffile'
The loading of myNet.mat came from code provided by the user. Considering that they use "clear all", and that they are using a script, we can see that they cannot possibly already have a trained network in an accessible variable, so they need to load their trained network into memory.
Hi,
I have the same problem, I am not loading any-pretranined netwoek, rather, I already have my network in a variable, say 'net'.
When I use classify, say C=classify(net, test_data) it gives me the same error, Error using classify (line 123)
Requires at least three arguments.
Would you be able topoint me the wrong I am doing?

Sign in to comment.

More Answers (1)

Thanks, Roberson. Sorry for the delay to accept your answer.

Tags

Community Treasure Hunt

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

Start Hunting!