-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Check shared variable values to determine volatility in posterior predictive sampling #6147
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6147 +/- ##
===========================================
+ Coverage 40.84% 87.94% +47.10%
===========================================
Files 91 91
Lines 20713 20707 -6
===========================================
+ Hits 8460 18211 +9751
+ Misses 12253 2496 -9757
|
ricardoV94
reviewed
Sep 26, 2022
f8ca43a
to
7e346c7
Compare
I'm not sure why precommit just dies after checking for links. |
5 tasks
7e346c7
to
9359f06
Compare
ricardoV94
requested changes
Sep 28, 2022
9359f06
to
7de0912
Compare
ricardoV94
reviewed
Sep 28, 2022
5d9228f
to
db4cbe5
Compare
ricardoV94
approved these changes
Sep 28, 2022
db4cbe5
to
a9f6ab5
Compare
a9f6ab5
to
f45ca4a
Compare
Neat one @lucianopaz! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this PR about?
Closes #6047.
This PR did two things:
SharedVariable
length have the name of the corresponding dimension.compile_forward_sampling_function
:constant_data
andconstant_coords
.These two arguments allow it to determine if a
SharedVariable
has changed after between a call tosample
andsample_posterior_predictive
. We have to note thatconstant_data
is only knowable ifsample_posterior_predictive
is called supplying anInferenceData
object, andconstant_coords
are only knowable ifsample_posterior_predictive
is called supplying anInferenceData
or anxarray.Dataset
object.The way
sample_posterior_predictive
is able to determine if a data container changed is by doing the following. It first checks theInferenceData.constant_data
group to find the values of data containers at inference time, and passes those into theconstant_data
argument ofcompile_forward_sampling_function
. When aSharedVariable
is found while walking the graph, it looks up the entry inconstant_data
, it it finds an entry, it checks whether the values in the dictionary match the values of theSharedVariable
at run time. If they match, theSharedVariable
is deemed not volatile, if they don't match, theSharedVariable
is considered volatile.To check if a dimension's coordinates changed,
sample_posterior_predictive
compares the model's coordinates to those found in the supplied trace (must be anInferenceData
orxarray.Dataset
to have this information). If the coordinates did not change, then the dimension name is added to theconstant_coords
set. Then, whencompile_forward_sampling_function
finds the dimension length's shared variable, it tries to see if its name is inconstant_coords
. If it is, then the dimension is not deemed volatile, if it isn't it is considered volatile.Checklist
Major / Breaking Changes
Bugfixes / New features
sample_posterior_predictive
, when supplied with anInferenceData
object, properly identifies if aMutableData
or mutable dimension has changed between a call topymc.sample
andpymc.sample_posterior_predictive
. If they have, then the descendant random variables are resampled, if they have not changed, then the descendant random variables are taken from theInferenceData.posterior
.Docs / Maintenance