Skip to content

Instantly share code, notes, and snippets.

@RANUX
Created November 23, 2017 14:10
Show Gist options
  • Save RANUX/a348a59215a201eb79a8d97f4bacefd4 to your computer and use it in GitHub Desktop.
Save RANUX/a348a59215a201eb79a8d97f4bacefd4 to your computer and use it in GitHub Desktop.
Simple neural network with 3 layers
import numpy as np
import math
inp = np.matrix([[0.9], [0.1], [0.8]])
wInp = np.matrix([[0.9, 0.3, 0.4],[0.2,0.8, 0.2],[0.1,0.5,0.6]])
xHid = wInp.dot(inp)
sigmoid = np.vectorize(lambda x: 1 / (1 + math.exp(-x)))
outHid = sigmoid(xHid)
wHidOut = np.matrix([[0.3,0.7,0.5],[0.6,0.5,0.2],[0.8,0.1,0.9]])
xOut = wHidOut.dot(outHid)
out = sigmoid(xOut)
out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment