Skip to content

Commit

Permalink
Fix for mcmc api transforms None for potential_fn (#2266)
Browse files Browse the repository at this point in the history
* Fix for mcmc api transforms None for potential_fn

* comment tidy

* fix lint

* fixes for multiprocessing

Co-authored-by: Neeraj Pradhan <prad.neeraj@gmail.com>
  • Loading branch information
2 people authored and fehiepsi committed Jan 21, 2020
1 parent ab7f9e5 commit b1e6020
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pyro/infer/mcmc/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,15 @@ def run(self, *args, **kwargs):
# If transforms is not explicitly provided, infer automatically using
# model args, kwargs.
if self.transforms is None:
if hasattr(self.kernel, 'transforms'):
if self.kernel.transforms is not None:
self.transforms = self.kernel.transforms
# Use `kernel.transforms` when available
if hasattr(self.kernel, 'transforms') and self.kernel.transforms is not None:
self.transforms = self.kernel.transforms
# Else, get transforms from model (e.g. in multiprocessing).
elif self.kernel.model:
_, _, self.transforms, _ = initialize_model(self.kernel.model,
model_args=args,
model_kwargs=kwargs)
# Assign default value
else:
self.transforms = {}

Expand Down

0 comments on commit b1e6020

Please sign in to comment.