Sunday, September 16, 2012

Solving XOR with MLP

Recently I tried to solve the XOR problem with the standard MLP + backprop. It was much harder than I expected. I wrote the MLP algorithm in Java and fed it with the XOR samples but the neural network wasn't able to learn the problem. I thought there is a bug in the implementation. I studied different implementations on the web but I found not error. Finally I found a C# code solving this problem but there was now significant difference in the code just the number of training epochs. I realized that several thousand of epochs is needed to build the right model. After some experiments I realized that the learning time can be decreased by using linear output layer instead of the sigmoid one. On the other it was really hard for me to find a simple implementation of MLP algorithm in Java. So here is my class which is not much longer than 100 lines of code. The main method solves the XOR problem.