Skip to content
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

Explicitly track constrained and unconstrained versions of transformed variables #808

Merged
merged 2 commits into from
Jan 7, 2018

Conversation

davmre
Copy link
Contributor

@davmre davmre commented Dec 16, 2017

This is a proposed fix to #807 (Automated transformations break log_joint computation). It:

  • modifies the auto_transform section of inference.initialize to maintain two dicts with clear semantics: latent_vars maps the original zs to qzs with matching support (possibly constructed as a transformation of an unconstrained qz), while latent_vars_unconstrained guarantees to contain versions of the zs and qzs supported over an unconstrained space. This ensures that any inference method that looks at latent_vars to compute a log joint will correctly substitute zs with qzs in the same space.
  • Updates HMC to wrap the 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 accesses qz.params; other inference methods that just treat qz as a Distribution (eg variational methods such as KLqp) should automatically do the right thing when given a qz having constrained support matching z.
  • Adds test cases for a simple beta-bernoulli model with automated transformations using HMC and KLqp.

@dustinvtran
Copy link
Member

Thanks Dave! Merging.

There's an interesting implication of this PR. Namely, ADVI works by transforming prior variables to the unconstrained space, then minimizing trainable Gaussians to the unconstrained posterior. What this PR does is transform trainable Gaussians to the constrained space, then minimize over the original space to the posterior. Parameterization of course matters—though I'd be hard-pressed to point to an example where one approach is preferred over the other (?).

@dustinvtran dustinvtran merged commit 09cd2af into blei-lab:master Jan 7, 2018
@davmre
Copy link
Contributor Author

davmre commented Jan 7, 2018 via email

@davmre
Copy link
Contributor Author

davmre commented Jan 7, 2018

I realized I misstated this slightly, because KL involves a ratio of densities it's invariant to parametrization (https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence#Properties) even though other information theoretic quantities like differential entropy aren't.

dustinvtran added a commit that referenced this pull request Jan 8, 2018
dustinvtran added a commit that referenced this pull request Jan 8, 2018
* fix pep8 from #808

* fix pep8 in tests_inference_auto_transform.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants