-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
NUTS step, when selected explicitly, requires the second derivative #2209
Comments
It also fails with |
@ColCarroll You are right, it actually fails at the initialization of the step function. But import numpy as np
import pymc3 as pm
with pm.Model():
uniform = pm.Interpolated('uniform', np.linspace(0, 1, 100), np.ones(100))
step = pm.Metropolis()
pm.sample(1000, step=step) doesn't produce any errors. I run it with Python 3 from the latest version of Anaconda3 and |
So I found that the error can be suppressed if I implement the In this case the |
This is because nuts needs a mass matrix (the |
@aseyboldt Yeah, the hessian seems to cause more problems than it's worth so I agree that we should default to an identity that we adapt during tuning using the trace. |
Yes, that makes sense. |
* Make spacing more compliant to PEP8 * Raise NotImplementedError from SplineWrapper grad operation Fixes #2209 * Instantiate SplineWrapper recursively to simplify the architecture * Create spline derivatives lazily * Move grad_op to a separate property * Add tests for SplineWrapper * Fix style issues
The referenced above PR #2211 solved the problem by throwing the correct type of exception for not implemented second derivatives and allowing However, @aseyboldt pointed out that it is a good idea to replace |
The NUTS sampler, when auto-assigned, requires only the first derivative (i.e. calls
grad()
method only for the operation itself).For example, this code for Interpolated distribution works:
However, when I try to specify
NUTS
orHamiltonianMC
step explicitly, it fails becauseInterpolated
distribution doesn't provide second-order derivatives (the variable returned bygrad()
doesn't havegrad()
method):According to the NUTS paper, it should require only first-order derivatives, but maybe I miss something.
So my question is: is it a problem or is it for some reason the expected behavior? In the second case I can add a second order gradient implementation to the
Interpolated
distribution that for example always returns zeros, but I don't understand why is it needed in the first place.The text was updated successfully, but these errors were encountered: