Skip to content

Commit

Permalink
messing around
Browse files Browse the repository at this point in the history
  • Loading branch information
wd15 committed Dec 6, 2019
1 parent f01f2b5 commit a21bba8
Show file tree
Hide file tree
Showing 4 changed files with 666 additions and 36 deletions.
322 changes: 322 additions & 0 deletions funcnn.ipynb

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions sand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import math

x = 3 # example values
y = -4

# forward pass
sigy = 1.0 / (1 + math.exp(-y)) # sigmoid in numerator #(1)
num = x + sigy # numerator #(2)
sigx = 1.0 / (1 + math.exp(-x)) # sigmoid in denominator #(3)
xpy = x + y #(4)
xpysqr = xpy**2 #(5)
den = sigx + xpysqr # denominator #(6)
invden = 1.0 / den #(7)
f = num * invden # done! #(8)

print(f)

# backprop

ini = 1.0
dnum = ini * invden
dinvden = ini * num
dden = -dinvden * (1.0 / den)**2
dsigx = 1.0 * dden
dx = sigx * (1 - sigx) * dsigx

dxpysqr = dden * 1.0
dxpy = 2 * xpy * dxpysqr
dx += dxpy * 1.0
dy = dxpy * 1.0

dsigy = dnum * 1.0
dy += sigy * (1 - sigy) * dsigy

print(dy)
print(dx)
76 changes: 40 additions & 36 deletions sandbox.ipynb

Large diffs are not rendered by default.

268 changes: 268 additions & 0 deletions sandbox0.ipynb

Large diffs are not rendered by default.

0 comments on commit a21bba8

Please sign in to comment.