-
Notifications
You must be signed in to change notification settings - Fork 905
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
autograd.scipy.stats.norm.ppf not implemented #558
Comments
Using your code snippet as an template, the structure looks like:
Most of the derivative code is boilerplate. Focusing on
(The Let's think about how
That should work. For the other arguments, it will get more complicated, but the same idea applies. The below code is everything you need, and is the start of a PR to autograd library. from scipy.stats import norm
from autograd.scipy.stats import norm as ag_norm
from autograd.extend import primitive, defvjp
from autograd.numpy.numpy_vjps import unbroadcast_f
ppf = primitive(norm.ppf)
defvjp(ppf,
lambda ans, x, loc=0.0, scale=1.0:
unbroadcast_f(x, lambda g: g * 1/ag_norm.pdf(ppf(x, loc, scale), loc, scale))
)
from autograd import grad
print(grad(ppf)(0.5))
print(grad(ppf)(0.0)) Does that give you enough information to do the rest? |
@CamDavidsonPilon when I run your code I get |
I am trying to make this work for a function like this:
Here
|
Aaah I've solved it! The problem is that it doesn't work for a list, which is what |
hi,
i would like to get the grad of the following function wrt to the 1st argument :
However, i found that norm.ppf has not been implemented in autograd.scipy.stats. But it is available in scipy:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html
Inside the autograd.scipy.stats.norm.py script, i found the wrappers for cdf and others function like pdf:
Could someone pls explain to me how does it work? How can i implement the wrapper for norm.ppf and norm.isf? Thanks
The text was updated successfully, but these errors were encountered: