Simple java ANN Multilayer Perceptrom (MLP).
Artificial Neural Network based on Multilayer Perceptron using EJML library for matrix management (the jar file is available here).
Algorithm based on Chapter 3 and Appendix A of the book Practical Neural Networks and Genetic Algorithms. If you want to learn more about this stuff, I recomend you to take a look to the book.
Currently the threeshold activation is not available (that's a bug pendent to fix). But you can use sigmoid activation for your purposes. If you take a look to the source code, for using a MLP the only thing you need to do is to create an ANN object:
// 2 inputs, 3 hidden neurons, 1 output, 1 hidden layer, 1.0 learning rate, activation function
ANN myNeuralNetwork = new ANN(2, 3, 1, 1, 1.0, ANN.ACTIVATION_SIGMOID);
An then to train the neural network just call train method:
// Input vector, target vector, minimum operations, maximum error
myNeuralNetwork.train(input, target, 10000, 0.01);
The format of the input labeled data for training should be:
-- -- -- --
| input1[0] input2[0] ... inputN[0] |
| input1[1] input2[1] ... inputN[1] |
| | | | |
| input1[M-1] input2[M-1] ... inputN[M-1] |
-- -- -- --
Where as you can see, in the double array:
[i][j] i->Input j->Number of input
After the nerual network has been trained, you will be able to classify your data. For this purpose, you can use the classify function:
output = myNeuralNetwork.classify(input);
And that's all!
Please, feel free to collaborate or give me some feedback. Hope this code help you!
It is available online on Robert Gordon University Aberdeen:
- Title page.
- Contents.
- Chapter 1 - An Introduction to Neural Networks.
- Chapter 2 - Artificial Neural Networks.
- Chapter 3 - The Back Propagation Algorithm.
- Chapter 4 - Some illustrative applications of feed-forward networks.
- Chapter 5 - Pre-processing input data.
- Chapter 6 - Network layers and size.
- Chapter 7 - Hopfield and recurrent networks.
- Chapter 8 - Competitive networks.
- Chapter 9 - Time dependant neurons.
- Chapter 10 - Implementing Neural Nets.
- Chapter 11 - An introduction to Evolution.
- Chapter 12 - The Genetic Algorithm.
- Chapter 13 - Some applications of Genetic Algorithms.
- Chapter 14 - Additions to the basic GA.
- Chapter 15 - Applying Genetic Algorithms to Neural Networks.
- Chapter 16 - Evolutionary Programming and Evolutionary Strategies.
- Chapter 17 - Evolutionary Algorithms in advanced AI systems.
- Appendix A - Appendix A Tips for Programmers.
- References.