Explicitly track constrained and unconstrained versions of transformed variables #808
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.
This is a proposed fix to #807 (Automated transformations break log_joint computation). It:
auto_transform
section ofinference.initialize
to maintain two dicts with clear semantics:latent_vars
maps the originalz
s toqz
s with matching support (possibly constructed as a transformation of an unconstrainedqz
), whilelatent_vars_unconstrained
guarantees to contain versions of thez
s andqz
s supported over an unconstrained space. This ensures that any inference method that looks atlatent_vars
to compute a log joint will correctly substitutez
s withqzs
in the same space.log_joint
computation by explicitly transforming back into the original (potentially constrained) latent space. I believe HMC needs special attention to work in the unconstrained space because it directly accessesqz.params
; other inference methods that just treatqz
as a Distribution (eg variational methods such as KLqp) should automatically do the right thing when given aqz
having constrained support matchingz
.