Last active
February 21, 2017 16:16
-
-
Save skeggse/74b4eae92111e34dcfc5bd493441cd65 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import scipy.optimize | |
# let check_grad work for x0: ndarray, like the documentation says it should | |
# see also: http://stackoverflow.com/q/15040263 | |
def check_grad(func, grad, x0, *args, **kwargs): | |
return scipy.optimize.check_grad(lambda xh: func(xh.reshape(x0.shape), *args), | |
lambda xh: grad(xh.reshape(x0.shape), *args).flatten(), | |
x0.flatten(), **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment