![:)](http://public.gamedev.net/public/style_emoticons/<#EMO_DIR#>/smile.gif)
i`ve been trying to learn some of the BP algorithem
and wrote the simplest code just to be sure i understand the basics, but somehow the net output is always about the same
and i cant figure why ?
if anyone can take a look i would be very gratefull . (should be easy for someone whose familiar with bp).
as input I entered two numbers between 0-1 wich are a and b
the output should be the subtraction between them ,output= (a - b) , might be negative..
i used simple sigmoid function .
was written in VB , i pasted just the hart of the code , its just for understanding , procedural way .
some Technical stuff , i scales the output to the range of -1 to 1 , should the output neuron recive an un scaled value of the error? like i did here
or how should it be?
so can someone explain What is wrong ?
thank you..
e = 2.718281828
alpha = 0.1
'input = two numbers between 0-1
a = Cells(2, 1)
b = Cells(2, 2)
truth = a - b 'correct answer
Sum1 = a + b
Sum2 = a + b
f1 = 1 / (1 + e ^ (-Sum1))
f2 = 1 / (1 + e ^ (-Sum2))
Sum3 = f1 + W13 + f2 * W23
Sum4 = f1 * W14 + f2 * W24
f3 = 1 / (1 + e ^ (-Sum3))
f4 = 1 / (1 + e ^ (-Sum4))
Sum5 = f3 * W35 + f4 * W45
f5 = 1 / (1 + e ^ (-Sum5))
answer = -1 + f5 * 2 ' need to spred over the area : -1 till 1
'backPropagate
err5 = (truth - answer + 1) / 2
err3 = err5 * W35
err4 = err5 * W45
err1 = err3 * W13 + err4 * W14
err2 = err3 * W23 + err4 * W24
'update wieghts
W13 = W13 + alpha * (f3 * (1 - f3)) * (f1 * W13) * err3
W23 = W23 + alpha * (f3 * (1 - f3)) * (f2 * W23) * err3
W14 = W14 + alpha * (f4 * (1 - f4)) * (f1 * W14) * err4
W24 = W24 + alpha * (f4 * (1 - f4)) * (f2 * W24) * err4
W35 = W35 + alpha * (f5 * (1 - f5)) * (f3 * W35) * err5
W45 = W45 + alpha * (f5 * (1 - f5)) * (f4 * W45) * err5