Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import numpy as np
  2.  
  3. sample = np.array([[0, 0, 1],
  4. [0, 1, 1],
  5. [1, 0, 1],
  6. [1, 1, 1]])
  7.  
  8. label = np.array([[0], [0], [1], [1]])
  9.  
  10. def activate(x):
  11. return 1/(1+np.exp(-x))
  12.  
  13. learning_rate = 1.0
  14. w0 = 2 * np.random.random((3, 1)) - 1 # le it cast in -1 to 1
  15.  
  16. for iter in range(1000):
  17. l0 = sample
  18. l1 = activate(np.dot(l0,w0))
  19. l1_err = label - l1
  20. w0_delta = l1_err * l1 * (1-l1)
  21. w0 += learning_rate*np.dot(l0.T,w0_delta)
  22. print w0_delta
  23. print l1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement