Monday, February 11, 2013

Back propagation neural network Java example source code

This example implements a multi-layer neural network, which will behave as an XOR gate after being trained using the back propagation algorithm.



The network has only two layers, the input layer and the output layer. It does not have any hidden layers. The input layer consist of two neurons and the output layer consist of only one neuron


You can find the NeuralNetwork.jar in the following link which includes the complete source code, compiled classes and images.
After downloading the jar file you can run the application by executing the following command.

java -classpath NeuralNetwork.jar com.neural.network.main.AppMain



First press Train button to calculate the weights. A message will be displayed saying you have successfully trained and the weights will get populated to the weight text boxes.

Afterwards you can select input values using the x1 an x2 combo boxes and Press Run button to test whether the neural network produces the correct output.



6 comments:

  1. Thankyou so much for posting this, it really helps me :D

    Regards

    ReplyDelete
  2. how to excrete this jar file please explain

    ReplyDelete
    Replies
    1. Navigate to the place where you have saved the jar NeuralNetwork.jar file and execute the run command given above (java -classpath NeuralNetwork.jar com.neural.network.main.AppMain)

      Delete
  3. Replies
    1. Thanks :). Since you guys find this post useful, I will try to post the theories and equations behind this as well. So it will be easier to understand the code.

      Delete