Skip to content

Instantly share code, notes, and snippets.

@AdityaSoni19031997
Created August 28, 2017 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdityaSoni19031997/ea7466ff1b06f72ff2cc803b0915a78f to your computer and use it in GitHub Desktop.
Save AdityaSoni19031997/ea7466ff1b06f72ff2cc803b0915a78f to your computer and use it in GitHub Desktop.
simplest Neural Net Possible
import numpy as np
X = np.array([ [0,0,1], [0,1,1], [1,0,1], [1,1,1] ])
y = np.array([ [0, 1, 1, 0] ])
w1 = np.random.random((3, 4)) - 0.5
w2 = np.random.random((4, 1)) - 0.5
for i in range(45000):
l1 = 1/(1+ np.exp(-(np.dot(X, w1))))
l2 = 1/(1+ np.exp(-(np.dot(l1,w2))))
delta_l2 = (y - l2) * (l2*(1-l2))
delta_l1 = delta_l2.dot(w2.T) * (l1*(1-l1))
w2 += l1.T.dot(delta_l2)
w1 += X.T.dot(delta_l1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment