Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- x = np.array([[1,0,1]])
- y = np.array([1,0])
- w_i = 2 * np.random.random((2,3))-1 #Input to Hidden Layer Weights
- w_o = 2 * np.random.random((2,2))-1 #Hidden Layer to Output Weights
- for i in range(6000):
- #here where the input and the first layer connection weight matrix did not matched
- h_layers = 1/(1+np.exp(-np.dot(x,w_i)))
- o_layers = 1/(1+np.exp(-np.dot(h_layers,w_o)))
- l2_delta = (y - o_layers)*(o_layers*(1-o_layers))
- l1_delta = l2_delta.dot(w_o.T) * (h_layers * (1-h_layers))
- w_o += h_layers.T.dot(l2_delta)
- w_i += x.T.dot(l1_delta) #This is also not working too.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement