Use Java open-source project joone to implement artificial intelligence programming (3)/Zhu Xianzhong Compilation
Running Neural Network
Now
However, the neural network has started training. We can test it and observe the results by providing the input mode to the neural network. The method used to run a neural network must first prepare the neural network for data processing. Currently
Neural network processing is a training method. First, we will delete the trainer from the output layer. Then we will replace the trainer with fileoutputsynapse so that we can record
Network output. The following code implements this:
Output. removeoutputsynapse (trainer ); Fileoutputsynapse Results = new fileoutputsynapse (); Results. setfilename (resultfile. gettext ()); |
Now we must reset the input stream-we will use the same file input stream as during training. This will fill in the same input used during neural network training.
Inputstream. resetinput (); Samples. resetinput (); Results. setmonitor (MONITOR ); Output. addoutputsynapse (results ); |
Then, we must restart all the threads that respond to the neural network.
Input. Start (); Hidden. Start (); Output. Start (); Trainer. Start (); |
Now that the thread has been restarted, we must set some basic configuration information for the next step. The following code completes these tasks.
Monitor. setpatterns (4 ); Monitor. settotcicles (1 ); Monitor. setlearning (false ); |
First, set the number of input modes to 4, because we want a neural network to process all the four input modes (which you previously provided to train the Neural Network ). Finally, set it to the learning method. After completing these steps, we can call the "go" method of the monitor.
After the training is completed, you will see the output file produces a result similar to list 2.
List 2: output from Neural Networks
0.012549763955262739
0.9854631848890223
0.9853159647305264
0.01783622084836082
We can see that the number in the first row in the above list is reasonably close to zero. This is good because the first line of the input training file, as shown in List 1, is expected to have zero results. Similarly, the second row is reasonably close to 1, which is also good because the expected result of the second row of the training file is also 1.
Conclusion
The joone engine encapsulates a lot of complexity in neural network programming. The example in this article shows the basic processes used by neural networks. Although the implementation of neural networks in the real world is much more complicated
The basic processing process is the same-data is provided to a neural network for training and a new pattern is generated for recognition. The routines here provide a good start for exploring with joone.