How to use trained network to predict or classify test data

52 views
Skip to first unread message

zhish...@gmail.com

unread,
Jun 17, 2019, 11:01:54 PM6/17/19
to mdCNN: Multidimensional CNN library in Matlab

In the package and DEMO, for example, the 3D MINST demo, I only saw Train function to train a network, but did not see a Classify or Predict function to 
use the trained network net to classify or predict a test data.  

For example,  after I get  "net"  after calling Train function,  how do I call a function like Classify as MATLAB Deep Learning Toolbox does :


   Predicted_Class  =  Classify(trainedNet, TestData)   ?


Thank you!


David

Hagay Garty

unread,
Jun 18, 2019, 5:59:19 AM6/18/19
to mdCNN: Multidimensional CNN library in Matlab
Hi, you can read in the documentation file on how to classify a single sample. Search for 'classify a single sample' in section 5.b

For your convenience, you can use the below code:


Batch       = zeros([net.layers{1}.properties.sizeOut   1]);

Batch(:,:,:,:,1) = sample_to_test;

net = feedForward(net, Batch , 1);

[~,netClassification]  = max(squeeze(net.layers{end}.outs.activation));

fprintf('sample classified as %d\n', netClassification);

 


steven...@gmail.com

unread,
Jun 18, 2019, 1:27:47 PM6/18/19
to mdCNN: Multidimensional CNN library in Matlab
Yes, yes, it works very well!

Thank you!


How about a regression case ?

Steven

Hagay Garty

unread,
Jun 19, 2019, 1:10:01 PM6/19/19
to mdCNN: Multidimensional CNN library in Matlab
Happy to hear it works well :)

For regression, you can take the last layer outputs as your prediction. 
i.e res = net.layers{end}.outs.activation;
Reply all
Reply to author
Forward
0 new messages