How to use a trained network to test new data set?

1 vue (au cours des 30 derniers jours)
Morteza Heidarinejad
Morteza Heidarinejad le 25 Juil 2017
Commenté : hanaa le 28 Mar 2021
Hi I have trained Alexnet network with my image data and saved it as a 'my_trained_net.mat'. Now In another script, I want to load it and just check it by new data set which has not been used for training. my code is as below:
net=load ('my_trained_net.mat');
[FileName,PathName]=uigetfile({'*.jpg';'*.tiff'},'Select Your picture');
newImage = strcat(PathName, FileName);
img = readAndPreprocessImage(newImage);
label = char(classify(net,img));
figure,imshow(img);
title(label);
this is exactly what I have used at the end of my training script to label some test images. the error is ' classify Requires at least three arguments' which means it does not recognize the 'net' as a SeriesNetwork object.
any comment or better way to do the same act is welcome thanks
  1 commentaire
Deepika B
Deepika B le 13 Fév 2020
how to convert the network as .mat file?

Connectez-vous pour commenter.

Réponse acceptée

Morteza Heidarinejad
Morteza Heidarinejad le 2 Août 2017
After a while struggling with my code, I got the answer. when the pre-trained network such as Alexnet is trained with the new set of images using trainNetwork command, new trained net is saved with a name that has been specified in the script. in my case, it was "mytrainnet". So in the new script, only for loading the trained net, Matlab recalls that name. what I did only was calling the net with the below line:
load my_trained_net
then it loaded with the name of "mytrainnet" in the workspace as SeriesNetwork object. Therefore the labeling of the new data set was easy by calling the:
label = char(classify(mytrainnet,img));
  2 commentaires
Yashwanth A
Yashwanth A le 14 Mar 2019
can you share your full code
hanaa
hanaa le 28 Mar 2021
Can you share your full code after classifying new images

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by