-
Notifications
You must be signed in to change notification settings - Fork 16
20190211 alexlew fix log categorical #118
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
base: master
Are you sure you want to change the base?
Conversation
In the case that all scores are negative infinity it seems more sensible to throw a human-readable error indicating that a vector of zeros is an invalid probability vector, as opposed to defaulting to the uniform. When a user calls log-cateogrical on a vector of zeros there is typically something wrong that happened in the user's code that they are better off explicitly handling themselves. |
My instinct is that (1) should be “yes,” since we’d like inference algorithms in Metaprob to be written like models, using the same random primitives. And I’m not sure I want importance resampling to error in (2), but could be convinced. |
|
Ah, the reversion to the version in your branch away from what was on Should we open an issue to change the implementation of importance resampling? |
I agree with you that the answer is yes. However, the behavior of log-categorical should be reasoned about independently of how importance resampling will use it. It is still possible for log-categorical to throw an error with impossible weights but importance resampling to handle this case as it pleases: either by failing (which is what happens in cgpm here where we check for infinities before calling
I'm interested in your reasoning why you would not prefer an error. My reasoning is that a vector of either all negative infinities or a single positive infinity is an indication that something has gone wrong upstream. Possibilities include: (i) the user may have provided impossible constraints, so that all possible target densities are zero (which could give a weight of log(0) = -inf or a math domain error); In all these cases my experience has been it is preferable for the user to know that something has gone wrong rather than for them to assume everything is OK and receive uniformly selected particles. |
|
Oh, I didn't see the discussion here until after I approved this PR. Will wait to merge. |
This fixes two things about the current implementation of
log-categorical:scores-to-probabilitiesfunction had reverted to the version on myexplorationsbranch, instead of the fixed version frommaster. This goes back to the version from master, plus one extra fix for stability: when all scores passed tolog-categoricalare negative infinity, we won't error.