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 errors in pymc sampler implementaton #1129

Merged
merged 2 commits into from
Apr 9, 2024
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
9 changes: 4 additions & 5 deletions sbi/samplers/mcmc/pymc_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,15 @@ def __init__(
self._device = device

# create PyMC model object
track_gradients = step in (pymc.NUTS, pymc.HamiltonianMC)
track_gradients = step in ("nuts", "hmc")
self._model = pymc.Model()
potential = PyMCPotential(
potential_fn, track_gradients=track_gradients, device=device
)
with self._model:
params = pymc.Normal(
self.param_name, mu=initvals.mean(axis=0)
) # dummy prior
pymc.Potential("likelihood", potential(params)) # type: ignore
pymc.DensityDist(
self.param_name, logp=potential, size=(initvals.shape[-1],)
)

def run(self) -> np.ndarray:
"""Run MCMC with PyMC
Expand Down
Loading