Hello all, currently I am working with the Neural Network toolbox. I used the "Generate Advanced Script" option at the end and made some modifications as to how the network is to divide up my data set into training, validation, and testing. I changed the default option from "dividerand" to "divideInd" and I specified which indices I wanted to be in training, validation, and testing. However, it seems that the training process is using the ENTIRE data set instead of exclusively using the training set I specified earlier. Is there a way around this? Also is there a way to check the confusion matrix for EACH individual set? (meaning confusion matrix using only training, validation, testing set) Below are modifications made to the code generated from NN toolbox:
inputs = datainput; targets = targetvalues;
% Create a Pattern Recognition Network
hiddenLayerSize = 35;
net = patternnet(hiddenLayerSize);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
% *MODIFICATIONS MADE HERE***
net.divideFcn = 'divideind'; % Divide data using indicies
%net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainInd = 1:300;
net.divideParam.valInd = 301:360;
net.divideParam.testInd = 361:420;
% For help on training function 'trainlm' type: help trainlm
% For a list of all training functions type: help nntrain
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'mse'; % Mean squared error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', …
'plotregression', 'plotfit'};
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% Recalculate Training, Validation and Test Performance
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs);
valPerformance = perform(net,valTargets,outputs);
testPerformance = perform(net,testTargets,outputs);
% View the Network
%view(net);
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(errors)
Thank you
Best Answer