0

Numpy dot multiplying

I tried numpy dot in a neural network design #code that fails import numpy as np def sig(x,d=False): if d: return 2*(1-x) return 1/(1+np.exp(-x)) inps=np.array([[0,0], [0,1], [1,0], [1,1]]) exout=np.array([[0],[1],[1],[1]]) np.random.seed(1) w0=2*np.random.random((2,4))-1 w1=2*np.random.random((4,1))-1 numberofexecutions=100000 for i in range(numberofexecutions): l0=inps l1=sig(np.dot(l0,w0)) l2=sig(np.dot(l1,w1)) l2e=exout-l2 l2d=l2e*sig(l2,d=True) l1e=l2d.dot(w1.T) l1d=l1e*sig(l1,d=True) w1+=l1.T.dot(l2d) w0+=l0.T.dot(l1d) #print(l2) ab=int(input()) bc=int(input()) ac=np.array([ab,bc]) l1a=sig(np.dot(ac,w0)) l2a=sig(np.dot(l1a,w1)) l3a=sig(np.dot(l2a,w2)) print(overflo(l3a)) #code that works import numpy as np def sig(x,d=False): if d: return 2*(1-x) return 1/(1+np.exp(-x)) inps=np.array([[0,0], [0,1], [1,0], [1,1]]) exout=np.array([[0],[1],[1],[1]]) np.random.seed(1) w0=2*np.random.random((2,4))-1 w1=2*np.random.random((4,1))-1 numberofexecutions=100000 for i in range(numberofexecutions): l0=inps l1=sig(np.dot(l0,w0)) l2=sig(np.dot(l1,w1)) l2e=exout-l2 l2d=l2e*sig(l2,d=True) l1e=l2d.dot(w1.T) l1d=l1e*sig(l1,d=True) w1+=l1.T.dot(l2d) w0+=l0.T.dot(l1d) print(l2)

20th Apr 2019, 1:19 AM
Imagine Existance
Imagine Existance - avatar
2 odpowiedzi
0
found awnser
27th Apr 2019, 4:28 AM
Imagine Existance
Imagine Existance - avatar
0
I dont see an issue, but I am new to neural networks.
20th Apr 2019, 1:20 AM
Imagine Existance
Imagine Existance - avatar