Skip to content

Conversation

@Sayam753
Copy link
Member

@Sayam753 Sayam753 commented Jun 6, 2020

Added Mean Field ADVI along with basic interface. I observe two different ways of adding VI approximations. One by tfd.JointDistributionSequential and other by tfd.MultivariateNormalDiag.

This interface incorporates the Sequential method. It may be possible to use tfd.MultivariateNormalDiag after having a flattened view of parameters. Any feedback at this implementation is welcomed.

  • Tests about convergence checks
  • Add convergence criteria example in quick start notebook - Will address this in another PR.
  • Include samples for untransformed variables as well
  • Handle shape issues with ArviZ while sampling
  • More user friendly optimizers
  • Configure atol for tests
  • Configure autobatching - Will address this in another PR.
  • Integrate Deterministics callback - Will address this in another PR.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Jun 6, 2020

Codecov Report

Merging #280 into master will decrease coverage by 0.64%.
The diff coverage is 79.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #280      +/-   ##
==========================================
- Coverage   90.62%   89.97%   -0.65%     
==========================================
  Files          29       32       +3     
  Lines        1919     2035     +116     
==========================================
+ Hits         1739     1831      +92     
- Misses        180      204      +24     
Impacted Files Coverage Δ
pymc4/distributions/multivariate.py 100.00% <ø> (ø)
pymc4/inference/sampling.py 93.40% <ø> (ø)
pymc4/variational/updates.py 63.63% <63.63%> (ø)
pymc4/variational/approximations.py 80.58% <80.58%> (ø)
pymc4/variational/__init__.py 100.00% <100.00%> (ø)

@Sayam753 Sayam753 changed the title Add Variational Inference Interface ENH: Add Variational Inference Interface Jun 7, 2020
@Sayam753
Copy link
Member Author

Sayam753 commented Jun 7, 2020

Requesting @ferrine, @twiecki for the review.

@junpenglao
Copy link
Member

You should subclass tf.Module in the metaclass, as it capture free parameters (anything that is a tf.Variable or tfp.util.TransformedVariable) automatically.

@Sayam753
Copy link
Member Author

Sayam753 commented Jun 7, 2020

Thanks @junpenglao . I will check how to use tf.Module and integrate here.

Copy link
Member

@ferrine ferrine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I have mostly API comments and suggestions

@twiecki
Copy link
Member

twiecki commented Jun 9, 2020

@Sayam753 I would plot the elbo on log scale.

@Sayam753
Copy link
Member Author

Sayam753 commented Jun 9, 2020

Yes @twiecki . I am adding the changes. 😃

@Sayam753
Copy link
Member Author

Here are some comparisons drawn for Mean Field ADVI in PyMC4, TFP and PyMC3 (gist). If this is the expected behaviour and for the next steps, shall I go about writing tests for the interface implemented so far? I wish to add Full Rank ADVI in another PR to avoid making this PR large enough to review.

@Sayam753 Sayam753 changed the title ENH: Add Variational Inference Interface WIP Add Variational Inference Interface Jun 14, 2020
@Sayam753 Sayam753 changed the title WIP Add Variational Inference Interface WIP: Add Variational Inference Interface Jun 14, 2020
@twiecki
Copy link
Member

twiecki commented Jun 15, 2020

Pretty weird that the results are so different, might be worth to dig a bit deeper.

@Sayam753
Copy link
Member Author

Yes @twiecki . Indeed the plots were weird. @ferrine suggested to use common random seed and same optimizer. Along with this, doing some minor fixes, I see good results. (gist). I have updated the PR now. It's ready to review.

@twiecki
Copy link
Member

twiecki commented Jun 20, 2020 via email

Copy link
Member

@ferrine ferrine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polising docs and tests is left before shipping. Some work is left beyond this PR (deterministic variables and flattening the model for full rank ADVI)

@ferrine
Copy link
Member

ferrine commented Jun 23, 2020

Looks good, I'll merge once tests pass

@Sayam753 Sayam753 changed the title WIP: Add Variational Inference Interface Add Variational Inference Interface Jun 23, 2020
@ferrine ferrine merged commit 9f5ff56 into pymc-devs:master Jun 23, 2020
@Sayam753 Sayam753 deleted the variational branch June 23, 2020 18:43
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.

4 participants