MATLAB: How to divide up the data using specified indices when using the TRAIN function in the Neural Network Toolbox

Deep Learning Toolboxdivideblockdivideintdividerand

The available functions that divide my data into training, validation, and testing sets do not include a function that allows me to pass in indices such that I can specify exactly which data points end up in which data set.

Best Answer

The ability to divide your data using specified indices is available in the Neural Network Toolbox version 6.0.
With The Neural Network Toolbox version 6.0, you may specify the divide function to be DIVIDEIND:
net.divideFcn = 'divideind';
This function will then be used to read in parameters containing the specific indices that you would like to use for training, validation and testing.
The names and properties of the parameters are:
Training indices:
net.divideParam.trainInd
Validation indices:
net.divideParam.valInd
Testing indicies:
net.divideParam.testInd
To work around this issue for Neural Network Toolbox version 5.1 (R2007b) and earlier, please download the attached MATLAB file and place it on your MATLAB path.
After, creating the network set the divideFcn to 'mydivide' and set the divideParams to the indices vector you wish to use.
The names of the parameters are
net.divideParam.trainNum
net.divideParam.valNum
net.divideParam.testNum