Introduction
Step One
I wrote a standard backpropegating neural network, and to test it, I decided to have it map XOR.
It is a 2-2-1 network (with tanh activation function)
X1 M1
O1
X2 M2
B1 B2
For testing purposes, I manually set up the top middle neuron (M1) to be an AND gate and the lower neuron (M2) to be an OR gate (both output 1 if true and -1 if false).
Now, I also manually set up the connection M1-O1 to be -.5, M2-O1 to be 1, and B2 to be -.75
So if M1 = 1 and M2 = 1, the sum is (-0.5 +1 -0.75 = -.25) tanh(0.25) = -0.24
if M1 = -1 and M2 = 1, the sum is ((-0.5)*(-1) +1 -0.75 = .75) tanh(0.75) = 0.63
if M1 = -1 and M2 = -1, the sum is ((-0.5)*(-1) -1 -0.75 = -1.25) tanh(1.25) = -0.8
This is a relatively good result for a "first iteration".
Step Two
I then proceeded to modify these weights a bit, and then train them using error propagation algorithm (based on gradient descent). In this stage, I leave the weights between the input and middle neurons intact, and just modify the weights between the middle (and bias) and output.
For testing, I set the weights to be and .5 .4 .3 (respectively for M1, M2 and bias)
Here, however, I start having issues.
My Question
I set my learning rate to .2 and let the program iterate through training data (A B A^B) for 10000 iterations or more.
Most of the time, the weights converge to a good result. However, at times, those weights converge to (say) 1.5, 5.7, and .9 which results in a +1 output (even) to an input of {1, 1} (when the result should be a -1).
Is it possible for a relatively simple ANN which has a solution to not converge at all or is there a bug in my implementation?