-
Notifications
You must be signed in to change notification settings - Fork 3
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
Handle user-provided log densities that throw exceptions #43
Comments
Stan separates two kinds of errors. If there are indexing errors, we tend to throw things that stop the algorithm because those aren't recoverable. If they are numerical errors like underflow, we treat them as rejections in the Stan algorithms. One thing to do would be to convert an exception into a negative infinite log density, which in any Metropolis setting will reject.
|
We could try to separate those errors at the python level (e.g., we could have it so Unfortunately, I believe as implemented today, BridgeStan raises all errors as RuntimeErrors, but other user-defined classes could follow this pattern |
This came up in a discussion with @gil2rok during #39, but applies to all of our algorithms. The user provided log_density_gradient function may throw an exception (we may even expect it to, e.g. if the parameters are out of support).
Currently, if this happens, the exception is propagated all the way up out of the algorithm and into the caller's code. This is probably not what we want to do. Instead, we could work as Stan does and treat any exception in the log density calculation as resulting in a rejection (assuming the algorithm contains an accept-reject step)
The text was updated successfully, but these errors were encountered: