Skip to content

Instantly share code, notes, and snippets.

@swanjson
Created December 7, 2020 10:30
Show Gist options
  • Save swanjson/75823d2ad9585a08e46f77c4cbab3c60 to your computer and use it in GitHub Desktop.
Save swanjson/75823d2ad9585a08e46f77c4cbab3c60 to your computer and use it in GitHub Desktop.
import numpy as np
X = [[2],
[3]]
Y = [[1],
[2]]
W_0 = [[0.30,0.53,0.94],
[0.46,0.80,0.21]]
W_1 = [[0.89,0.39],
[0.74,0.41],
[0.24,0.06]]
W_0nump = np.array(W_0)
W_0T = W_0nump.transpose()
x_nump = np.array(X)
temp = np.matmul(W_0T,x_nump)
h = np.tanh(temp)
z = np.arctanh(h)
W_1nump = np.array(W_1)
W_1T = np.transpose(W_1nump)
Y_hat = np.matmul(W_1T,h)
Y_hat2 = np.matmul(W_1T,temp)
h_nump = np.array(h)
z = np.arctanh(h_nump)
bias = .208194682
yhat1 = 1.83209
yhat2 = .84381
yres1 = 1
yres2 = 2
hspec1 = .96258698
hspec2 = .99802629
hspec3 = .98687761
hspec = hspec1
yres = yres1
yhat = yhat1
weightspec = .89
errorDeriv = (2*((yhat-yres)))*(1-np.tanh(np.tanh((weightspec*hspec)+bias)))*(hspec)
print(errorDeriv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment