Skip to content

Instantly share code, notes, and snippets.

@kjw0612
Last active November 17, 2015 19:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjw0612/0352ac3966e7653b61bd to your computer and use it in GitHub Desktop.
Save kjw0612/0352ac3966e7653b61bd to your computer and use it in GitHub Desktop.
A Neural Network in 11 lines of Python
X = np.array([ [0,0,1],[0,1,1],[1,0,1],[1,1,1] ])
y = np.array([[0,1,1,0]]).T
syn0 = 2*np.random.random((3,4)) - 1
syn1 = 2*np.random.random((4,1)) - 1
for j in xrange(60000):
l1 = 1/(1+np.exp(-(np.dot(X,syn0))))
l2 = 1/(1+np.exp(-(np.dot(l1,syn1))))
l2_delta = (y - l2)*(l2*(1-l2))
l1_delta = l2_delta.dot(syn1.T) * (l1 * (1-l1))
syn1 += l1.T.dot(l2_delta)
syn0 += X.T.dot(l1_delta)
##
@kjw0612
Copy link
Author

kjw0612 commented Sep 9, 2015

fdsfdsf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment