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

SteinVI: Recompute Score Function* For Each Particle Interaction in the Attractive Force #1947

Merged
merged 3 commits into from
Jan 12, 2025

Conversation

OlaRonning
Copy link
Member

@OlaRonning OlaRonning commented Jan 10, 2025

Previously

The score function(1) in the attractive force was computed once for each particle and reused. While this is cheap, it also biases the Stein force.

Changes

  • The score function is recomputed with fresh samples for every particle interaction.
  • Added comments with equation references.
  • Factored out the loss function in preparation for making it a class parameter that allows SteinLoss and ELBOs.
  • ruff format v0.7.1 -> v0.9

The behavior-changing code is in einstein/steinvi.py and example/stein_bnn.py. The rest is from using the latest ruff.

Effect

  • More stable optimization (Stein force fluctuates less at minimum)
  • BNN example no longer needs tight initialization.
  • Increased computation time, but outweighed by improvement in stability

(1) It is not actually a score function (grad(log p(x|D))(x)) as we are taking the gradient of an ELBO, not the log posterior log p(x|D)).

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@fehiepsi fehiepsi merged commit 986da95 into pyro-ppl:master Jan 12, 2025
10 checks passed
@OlaRonning OlaRonning deleted the steinvi/simp-attr branch January 12, 2025 21:26
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