MATLAB Answers

How can I use my CNN after training (Image Recognition)

조회 수: 5(최근 30일)
zayeema masoom
zayeema masoom 22 Jan 2020
댓글: zayeema masoom 26 Jan 2020
Hello everyone,
I'm new to MATLAB but am working on a project so I've problem using and understanding new function and I'm not too good at deep learning with respect to hands on approach.
I've written code for CNN and trained the network somehow but I'm not able to use that trained network, will be greatful for any help.
Here's part of my code: -
%% Creating the CNN
% I've defined inputlayer, middlelayer and finallayer and it's training successfully
layers = [
options = trainingOptions('sgdm','MaxEpochs',50, ...
convnet = trainNetwork(trainData,layers,options);
thisNetwork = convnet;
If I load my network with command using : -
I don'd get any error.
Then when I try to use it using: -
result = TheTrainedCNN('test.jpg');
I get error as:-
Unrecognized function or variable 'TheTrainedCNN'.

  댓글 수: 0

Sign in to comment.


Adam 22 Jan 2020
When you saved the file the network was called 'thisNetwork'.
That is what this instruction saves:
'TheTrainedCNN' is the filename so when you load it as:
your network will be deposited back into the workspace as 'thisNetwork', not 'TheTrainedCNN'.

  댓글 수: 3

zayeema masoom
zayeema masoom 23 Jan 2020
I tried this: -
result = convnet('test.jpg')
But got this: -
Index exceeds the number of array elements (1).
Adam 23 Jan 2020
Like I said, your network is called thisNetwork. You should be able to see it in your workspace. I'm not quite sure how you would get from my answer that you should try:
result = convnet( 'test.jpg' )
and expect it to work!
zayeema masoom
zayeema masoom 26 Jan 2020
Yeah I can surely see "TheTrainedCNN" in my workspace but still can't use it.

Sign in to comment.

Translated by