Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- sample = np.array([[0, 0, 1],
- [0, 1, 1],
- [1, 0, 1],
- [1, 1, 1]])
- label = np.array([[0], [0], [1], [1]])
- def activate(x):
- return 1/(1+np.exp(-x))
- learning_rate = 1.0
- w0 = 2 * np.random.random((3, 1)) - 1 # le it cast in -1 to 1
- for iter in range(1000):
- l0 = sample
- l1 = activate(np.dot(l0,w0))
- l1_err = label - l1
- w0_delta = l1_err * l1 * (1-l1)
- w0 += learning_rate*np.dot(l0.T,w0_delta)
- print w0_delta
- print l1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement