-
Notifications
You must be signed in to change notification settings - Fork 246
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
Merge postprocess_fn into the fori_collect loop #1910
Conversation
# We have two extra calls to the model to get deterministic values: | ||
# 1. transform the init state | ||
# 2. transform state during the loop | ||
assert GLOBAL["count"] == 5 + num_traces_for_heuristic |
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.
Could you add an assertion that x_copy
is in the get_samples
? Perhaps test_mcmc.py would be a better place for the suggested test.
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.
yes, it is tested at
numpyro/test/infer/test_mcmc.py
Line 161 in 5c2eafa
assert samples["logits"].shape == (num_samples, N) |
fields = [fields] if len(collect_fields) == 1 else list(fields) | ||
site_values = jax.tree.flatten(fields[0])[0] | ||
if len(site_values) > 0: | ||
fields[0] = postprocess_fn(fields[0], *x[1:]) |
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.
Could you clarify what is stored in fields[1:]
if len(collect_fields) >1
since we only need to run postprocess_fn
on the first element?
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.
The first one is the sample field. The rest are extra fields.
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.
I see, then it makes sense that constraints are only applied to the first field.
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.
Thanks for clarifications
Test: current tests are passing