Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import numpy as np
  2.  
  3.  
  4. x = np.array([[1,0,1]])
  5. y = np.array([1,0])
  6. w_i = 2 * np.random.random((2,3))-1 #Input to Hidden Layer Weights
  7. w_o = 2 * np.random.random((2,2))-1 #Hidden Layer to Output Weights
  8.  
  9.  
  10. for i in range(6000):
  11. #here where the input and the first layer connection weight matrix did not matched
  12. h_layers = 1/(1+np.exp(-np.dot(x,w_i)))
  13.  
  14.  
  15. o_layers = 1/(1+np.exp(-np.dot(h_layers,w_o)))
  16. l2_delta = (y - o_layers)*(o_layers*(1-o_layers))
  17. l1_delta = l2_delta.dot(w_o.T) * (h_layers * (1-h_layers))
  18. w_o += h_layers.T.dot(l2_delta)
  19. w_i += x.T.dot(l1_delta) #This is also not working too.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement