MATLAB: Select matrix for training,testing and validation on ANN

netneuralnetworktestingtrainingvalidation

Hello to all,
completeX = [1:+1:100;2:+2:200]';
completeY = [1:+1:100]';
From my data set i divided in a specific form and I got a Xtrain (72×2), Xcv (8×2) and Xtest (20×2)
i would like to tell the net which matrix is the training, validation and testing, instead of matlab performing the random spliting, is that possible?
net = fitnet(10,'trainlm');
net.divideParam.train = Xtrain;
net.divideParam.val = Xcv;
net.divideParam.test = Xtest;
[net, TR] = train(net,completeX',completeY');
Hope it was clear,
Thanks!

Best Answer

Hi,
You may try dividing the whole dataset based on the indices as understandable from the question. Below code may help.
completeX = [1:+1:100;2:+2:200]';
completeY = [1:+1:100]';
net = fitnet(10,'trainlm');
net.divideFcn = 'divideind';
net.divideParam.trainInd = 1:72;
net.divideParam.valInd = 73:80;
net.divideParam.testInd = 81:100;
[net, TR] = train(net,completeX',completeY');
TR.trainInd , TR.valInd , TR.testInd will give the indices of training , validation and test data which can be used to find performance of the network. You may manipulate above indices vector as required.