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 init_params bug in hmcgibbs #1673

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Changes from 1 commit
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
16 changes: 11 additions & 5 deletions numpyro/infer/hmc_gibbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ def init(self, rng_key, num_warmup, init_params, model_args, model_kwargs):
).get_trace(*model_args, **model_kwargs)

rng_key, key_z = random.split(rng_key)
gibbs_sites = {
name: site["value"]
for name, site in self._prototype_trace.items()
if name in self._gibbs_sites
}

gibbs_sites = {}

for name, site in self._prototype_trace.items():
if init_params and name in init_params:
gibbs_sites[name] = init_params[name]
init_params.pop(name)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can combine those lines into ... = init_params.pop(name).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!


elif name in self._gibbs_sites:
gibbs_sites[name] = site["value"]

model_kwargs["_gibbs_sites"] = gibbs_sites
hmc_state = self.inner_kernel.init(
key_z, num_warmup, init_params, model_args, model_kwargs
Expand Down