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

조회 수: 6 (최근 30일)
zayeema masoom
zayeema masoom 2020년 1월 22일
댓글: Rik 2021년 3월 23일
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 = [
inputlayer
middlelayer
finalayer
];
options = trainingOptions('sgdm','MaxEpochs',50, ...
'InitialLearnRate',0.000001);
convnet = trainNetwork(trainData,layers,options);
thisNetwork = convnet;
save('TheTrainedCNN','thisNetwork');
If I load my network with command using : -
load('TheTrainedCNN');
OR
load('TheTrainedCNN.mat')
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'.
  댓글 수: 1
Rik
Rik 2021년 3월 23일
@zayeema masoom Which thread do you think this is duplicating? And why didn't you respond to Adam?

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam
Adam 2020년 1월 22일
When you saved the file the network was called 'thisNetwork'.
That is what this instruction saves:
save('TheTrainedCNN','thisNetwork');
'TheTrainedCNN' is the filename so when you load it as:
load('TheTrainedCNN');
your network will be deposited back into the workspace as 'thisNetwork', not 'TheTrainedCNN'.
  댓글 수: 1
Adam
Adam 2020년 1월 23일
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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by