Created
August 28, 2017 14:38
-
-
Save AdityaSoni19031997/ea7466ff1b06f72ff2cc803b0915a78f to your computer and use it in GitHub Desktop.
simplest Neural Net Possible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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