I ask Xi Xi, a few days ago to play with a bit of MATLAB in the use of Neural network toolbox, and suddenly there is "palpable" the sense of the well-being. The other is nothing, but the data structure of the neural network is a bit "weird", if careless will cause the toolbox error. Here is the correct open posture for the Neural Network Toolbox, for gentlemen Reference:
1. Open matlab, enter nntool at the command line, the following interface will appear:
Figure 1 Neural Network Toolbox main interface
The most important of which is divided into 6 parts: The 1th part shows the input data of the system, the 2nd part is the expected output of the system, the 3rd part is the computing output of the network, and the 4 is the error of the network, that is, the difference between 2 and 3; The 5th part presents the established neural network example. The 6th part of the two buttons are responsible for data import and the establishment of network model respectively.
2. Click the "Import" button to import input data and target output data separately (data can be imported from the workspace or imported from a file):
Figure 2 Importing an input dataset
Figure 3 Importing the desired output dataset
The following is the case for importing the data:
Figure 4 What happens after the data is imported
Important note: The data of the neural network is listed as the basic unit, that is, the input and output data must be the same number of columns, otherwise an error will be given. If the original data is organized in a behavioral unit, you can first implement transpose in MATLAB and then import, that is, B = A '.
3. Now that the data is needed, the next step is to build a neural network model to learn about the data set. The following steps take the BP network as an example, first click on the "New" button, the following interface appears:
Figure 5 Neural network Model settings
Several important parts have been framed in the figure above: 1 is used to define the name of the neural network, 2 is used to select the type of neural network, 3 is used to select the input data of the network, 4 is used to determine the expected output data of the network, 5, 6, 7 respectively, the main mechanism function of the neural network is set; 8 Set the ; 9 is used to select each network layer (it should be explained that the 1th layer refers to the hidden layer rather than the input layer), so that the number of neurons in the layer and the transfer function can be set at 10 and 11; 12 buttons can be used to view the structure of the current set of neural networks (the following drawings) , click the 13 button to generate the corresponding neural network model. The front is simply a brief introduction of the role of the various parts, the specific parameters should be how to set only you to learn the relevant literature, there is no longer a lot of words.
Figure 6 Neural network Structure preview
4. Now that the model and data are available, the next step is to train the model. Back to the main interface as follows:
Figure 7 back to the main interface
Select the neural network model we just established, then click on the "Open" button and the following interface will appear:
Figure 8 Neural network interface
Here we mainly introduce the contents of two tabs, one is "Train" and the other is "Adapt". The neural network can be trained by clicking on the "Train" tab and making the appropriate settings:
Figure 9 Model main information settings
Figure 10 Model-specific parameter settings
After setting up all the information, click "Trainnetwork" button to train the network. After the training is completed there will be a result information interface, as follows:
Figure 11 Training Result Feedback
5.OK, now that the model training is over, the next step is to validate the model we trained. The validation input and validation output are imported first, and this step is no longer revisited. Then come to the model validation interface:
Figure 12 Verifying data after import
Figure 13 Verifying parameter settings
Red box 1 Set the input and verification output of the network, 2 set the network output and error conditions of the storage name; These are all completed after clicking "Adapt Network". After that, the following prompt interface will appear:
Figure 14 Tip Interface
Then go back to the neural network main interface as follows:
Figure 15 Network validation Results
In the interface, there will be more than two sets of data framed by the red box, respectively, the output of the network and the corresponding output error. Specific data can be opened by double-clicking on them to open the view.
Important NOTES:
The input and output data for the neural network require a sample per column, which may need to be transpose as usual.
Otherwise, the number of input/output samples may be reported as different errors.
If the "Input data size does not match net.inputs{1}.size" error occurs, it is because creating a neural network is caused by setting the number of inputs different from the number of inputs of the sample data, re-creating the appropriate neural network.