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

fix elbo normalization with multi_sample_guide=True #1728

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions numpyro/infer/elbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def get_model_density(key, latent):
return model_log_density

num_guide_samples = None
for name, site in guide_trace.items():
for site in guide_trace.values():
if site["type"] == "sample":
num_guide_samples = site["value"].shape[0]
break
Expand Down Expand Up @@ -210,8 +210,6 @@ def get_model_density(key, latent):
# log p(z) - log q(z)
elbo_particle = model_log_density - guide_log_density

# log p(z) - log q(z)
elbo_particle = model_log_density - guide_log_density
if mutable_params:
if self.num_particles == 1:
return elbo_particle, mutable_params
Expand Down
Loading