MATLAB: How to change the divide function for the training, testing and validation data of the neural network

appdividedividefcnfunctionindexnftoolnprtoolrandom

When using 'nftool' (Neural Fitting) or 'nprtool' (Neural Network Pattern Recognition), the apps default to use the 'random' method of dividing the data into training, validation, and testing subsets. I must then select percentages for how I want the data to be divided between each set.
How do I distribute sample data between training, validation and testing using a different method, such as by index?

Best Answer

Refer to the following documentation page for details about the four different divide functions:
This page describes how each divide function separates the data into training, validation and testing subsets. Additionally, it explains which properties of the network you will need to set in order to use each method. For example, in order to use 'divideind', you must set the 'divideFcn' of the network to 'divideind', as well as specify certain 'divideParam' values which correspond to the indices that will divide the data.
If you are using an app such as 'nftool' or 'nprtool', the 'divideFcn' is set to 'dividerand' by default. In order to use a different dividing method, you can follow this workaround:
1. Use 'nftool' or 'nprtool' with the default divide method to train your network.
2. Proceed through the app until you get to the page "Save Results". You will have an option to create a script from the app. Select the "Simple Script" button.
3. A script will open with the generated code for training your network. Within this script, you can change the code that sets the 'divideFcn' and 'dividParam' values.
4. Run this script to train the network again.