-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix for #3210 without computing the Bayes network #3273
Fix for #3210 without computing the Bayes network #3273
Conversation
…istently with scipy.stats. Added test and updated example code.
…at py27 joblib does not make tests fail
…n PR pymc-devs#3214. It uses a context manager inside `draw_values` that makes all the values drawn from `TensorVariables` or `MultiObservedRV`s available to nested calls of the original call to `draw_values`. It is partly inspired by how Edward2 approaches the problem of forward sampling. Ed2 tensors fix a `_values` attribute after they first call `sample` and then only return that. They can do it because of their functional scheme, where the entire graph is recreated each time the generative function is called. Our object oriented paradigm cannot set a fixed _values, it has to know it is in the context of a single `draw_values` call. That is why I opted for context managers to store the drawn values.
pymc3/distributions/distribution.py
Outdated
return func(*values) | ||
output = func(*values) | ||
return output | ||
print(param, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops.
I am in favor of merging this, any comment? @twiecki @aseyboldt |
@junpenglao, I noticed that I still have to write to the release notes and do some minor changes in distributions that call |
…ultivariate distributions that make many calls to draw_values or other distributions random methods within their own random.
Great, this looks waaay better and simpler than before. I think we should merge this after merge conflicts are fixed. |
Great work @lucianopaz ;-) |
Indeed, if this doesn't demonstrate tenacity I don't know what would :). Great job! |
Fix for #3210 which uses a completely different approach than PR #3214. It uses a context manager inside
draw_values
that makes all the values drawn fromTensorVariables
orMultiObservedRV
's available to nested calls of the original call todraw_values
.It is partly inspired by how Edward2 approaches the problem of forward sampling. Ed2 tensors fix a
_value
attribute after they first callsample
and then only return that. They can do it because of their functional scheme, where the entire graph is recreated each time the generative function is called. Our object oriented paradigm cannot set a fixed_value
attribute because we would want two independent calls to an RV'srandom
,sample_prior_predictive
orsample_posterior_predictive
methods to give different results. This means thatdraw_values
has to know the context on which it was used.The original implementation of
draw_values
is almost entirely preserved. The lines that do thewhile missing_input
loop, which could potentially slow down forward sampling, could be removed if we did a topological sort ofparams
. Maybe we could consider doing that in a separate PR.