/SimpleNeuralNetwork

A very simple and basic neural network implemented in java

Primary LanguageJava

SimpleNeuralNetwork

A very simple and basic neural network implemented in java
Neural network is a fully connected feed forward network using matrices.

Setup

The Neural Network

To create a 2-layer neural network with 3 input neurons, 5 hidden neurons and 3 output neurons simply do this:


NeuralNetwork nn = new NeuralNetwork(3, 5, 2);

If you want it to have more hidden layers you can just add them in the construcor like so:


NeuralNetwork nn = new NeuralNetwork(3, 5 ,5 10, 10, 2);

This will then create a NN with 3 input neurons , 2 output neurons and 4 hidden layers having 5, 5, 10, 10 neurons.

The Activation Function

The ActivationFunction can be set using:


nn.setActivationFunction(ActivationFunction af);

I have included the most common ones in the ActivationFunction interface, but you can write your own by implementing said interface.
The included ones are: Identity, Binary Step, Sigmoid, TanH, ArcTan, Softsign, ReLU, Leaky ReLU, Sinusoid, Sinc and Gaussian