MATLAB Answers

Translated by

이 페이지의 내용은 영어에서 자동 번역되었습니다. 자동 번역 기능을 해제하려면 "<a class="turn_off_mt" href="#">여기</a>"를 클릭하십시오.


Classify requires at least 3 arguments

Asked by Raphael Ruschel on 1 Nov 2018
Latest activity Commented on by hana razak on 20 Feb 2019
I am having trouble when trying to use the "classify" function to evaluate the performance of my neural network.
I am using the following code:
net = load('mynet.mat'); %this returns my previsouly trained SeriesNetwork object
test_folder = './test_data';
test_images = imageDatastore(test_folder,'FileExtensions','.jpg');
[Y,scores] = classify(net,test_images);
But the classify function throws me an error that it requires at least 3 arguments, which means it is trying to use the classify function from the statistics package.
What can I make do force the use of the classify from the deep learning package?


Sign in to comment.

3 Answers

Answer by Walter Roberson
on 1 Nov 2018
Edited by Walter Roberson
on 5 Nov 2018
 Accepted Answer

net = load('mynet.mat'); %this returns my previsouly trained SeriesNetwork object
Not exactly. The output of load applied to a mat file, is a struct that has one field for each variable loaded. So you would need where the first net is the struct returned from load and the second is the variable loaded.


That was indeed the case! I can't believe I let that simple mistake pass unnoticed. Thank you so much!
Hi Walter:
I got the same ERROR: ‘ERROR using classify, Requires at least three arguments’
while using
net =importKerasLayers(modelfile,...
%net input size is (29,13,1)
predict=classify(net, input)
Could you give me some advice?
Keras layers are not a trained network . They are more instructions on how to train a network . You need to pass an imagestore and the layers to trainNetwork to create a net to use with classify.

Sign in to comment.

Answer by Alaa ElDin ElHilaly on 22 Jan 2019

I face the same problem. would you please elaborate more about your suggested solution. I have trained the network and keeps giving me (required at least 3 arguments)


When you load() a .mat file and you assign to output, the output is not directly any of the variables saved in the .mat file. Instead the output is a struct with one field for each variable loaded from the .mat file. For example if the .mat file contained the variables 'puppy' and 'butterfly', then
net = load('mynet.mat');
is not going to directly store puppy or butterfly in net, and it is not going to store into variables named puppy and butterfly in the environment of the function. Instead net would become a struct with fields named puppy and butterfly and net.puppy would hold whatever was in the puppy variable in mynet.mat

Sign in to comment.

Answer by hana razak on 19 Feb 2019

Me too. I've got same ERROR when using webcam to classify the fast RCNN
camera = videoinput('winvideo', 2, 'MJPG_1024x576');
net = load('detector200.mat');
while true
picture = getsnapshot(camera);
picture = imresize(picture,[150,150]);
label = classify(net, picture);
Here are the errors,
Error using classify (line 123)
Requires at least three arguments.
Error in webcam_object_classification (line 7)
label = classify(net, picture);
I've tried as suggested in command window and it showed this,
>> net.detector200
ans =
fasterRCNNObjectDetector with properties:
ModelName: 'normal'
Network: [1×1 vision.cnn.FastRCNN]
RegionProposalNetwork: [1×1 vision.cnn.RegionProposalNetwork]
MinBoxSizes: [39 30]
BoxPyramidScale: 1.2000
NumBoxPyramidLevels: 14
ClassNames: {'normal' 'abnormal' 'Background'}
MinObjectSize: [18 18]
BUT I don't know how to use it in the code.
Any help would be greatly appreciated.
Thank you so much


label = classify(net.detector200, picture);
It didn't work. I got the same error.
Is there any other solution?
Thank you

Sign in to comment.

Translated by