I have trained xor neural network in Matlab and got these weights:
iw: [-2.162 2.1706; 2.1565 -2.1688]
lw: [-3.9174 -3.9183]
b{1} [2.001; 2.0033]
b{2} [3.8093]
Just from curiosity I have tried to write MATLAB code which computes the output of this network (2 neurons in hidden layer, and 1 in output, TANSIG activation function).
Code that I got:
l1w = [-2.162 2.1706; 2.1565 -2.1688];
l2w = [-3.9174 -3.9183];
b1w = [2.001 2.0033];
b2w = [3.8093];
input = [1, 0];
out1 = tansig (input(1)*l1w(1,1) + input(2)*l1w(1,2) + b1w(1));
out2 = tansig (input(1)*l1w(2,1) + input(2)*l1w(2,2) + b1w(2));
out3 = tansig (out1*l2w(1) + out2*l2w(2) + b2w(1))
The problem is when input is lets say [1,1], it outputs -0.9989, when [0,1] 0.4902. While simulating network generated with MATLAB outputs adequately are 0.00055875 and 0.99943.
What I'm doing wrong?