-
-
Save adamobeng/72751b9571f2141ea194c5ba4c422aba to your computer and use it in GitHub Desktop.
neural network in a single Tweet
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
from numpy import * | |
r=random | |
c=hstack | |
p=dot | |
N=r.randn | |
s=lambda x:1/(1+exp(-x)) | |
a=lambda x:s(x)*(1-s(x)) | |
h,j=X.shape | |
w=N(5,j+1) | |
e=N(1,6) | |
for i in r.randint(0,h,1000*h):o=c((1,X[i]));m=p(w,o);n=c((1,s(m)));d=p(e,n);b=0.02*(Y[i]-s(d));g=b;w+=outer(e[:,1:]*a(d)*a(m),o)*b;e+=n*g*a(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment