How to get validation test and training errors of a neural network?
Show older comments
I have created and trained a neural network using the following code .I want to know how to get the training testing and validation errors/mis-classifications the way we get using the matlab GUI.
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize = 25;
net = patternnet(hiddenLayerSize);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = trainper/100;
net.divideParam.valRatio = valper/100;
net.divideParam.testRatio = testper/100;
% Train the Network
[net,tr] = train(net,x,t);
Accepted Answer
More Answers (1)
Greg Heath
on 31 Jul 2016
clear all, clc
[ x, t ] = simplefit_dataset;
net = fitnet;
rng('default') % For reproducibility
[ net tr y e ] = train( net, x, t );
% y = net(x); e = t - y;
tr = tr % No semicolon: LOOK AT ALL OF THE GOODIES!!!
msetrn = tr.best_perf
mseval = tr.best_vperf
msetst = tr.best_tperf
Hope this helps
Thank you for formally accepting my answer
Greg
5 Comments
Newman
on 31 Jul 2016
Greg Heath
on 4 Aug 2016
SORRY!!!
I didn't notice that your problem is classification instead of regression.
Will post more after I go upstairs and have a snack.
Greg
Newman
on 4 Aug 2016
Mohamed Nedal
on 30 Nov 2019
Edited: Mohamed Nedal
on 14 Dec 2019
Dear @Greg,
Could you please elaporate on the difference between msetrn, mseval, and msetst?
If I want to assess the overall performance of the NN and want to find the MSE for the NN as a whole, Which one should I use?
Mohamed Nedal
on 30 Nov 2019
If I wrote this:
rmse = sqrt(mean(e));
Does this give me the RMSE of the whole NN?
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!