Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix for "gradient not yet implemented" error #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

j-towns
Copy link
Collaborator

@j-towns j-towns commented Mar 1, 2017

There are various (admittedly quite obscure) situations where Numpy might throw a keyerror, and it could be incorrectly caught by this try ... except block, which would obscure the correct error. This slight rearrangement should prevent that from happening.

@j-towns
Copy link
Collaborator Author

j-towns commented Mar 1, 2017

A dumb example of what I'm talking about:

from autograd.core import primitive
from autograd import grad
import numpy as np

@primitive
def sin(x):
    return np.sin(x)

def sin_vjp(g, ans, vs, gvs, x):
    # generate a keyerror
    d = dict()
    d['a']

sin.defvjp(sin_vjp)

grad(sin)(1.)

seems to throw three exceptions, two of which are

NotImplementedError: Gradient of sin w.r.t. arg number 0 not yet implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant