Skip to content

Instantly share code, notes, and snippets.

@slchangtw
Created May 27, 2017 11:13
Show Gist options
  • Save slchangtw/34e9404f604ad453c0e5a6817241594e to your computer and use it in GitHub Desktop.
Save slchangtw/34e9404f604ad453c0e5a6817241594e to your computer and use it in GitHub Desktop.
from ad import adnumber
from ad import admath
import numpy as np
# ref: http://cs231n.github.io/optimization-2/
w = adnumber(np.array([2, -3, -3]))
x = adnumber(np.array([-1, -2, 1]))
f = 1 / (1 + admath.exp(-sum(w * x)))
f.gradient(w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment