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 pyro parameter nodes not showing up in graph of pyro deterministic nodes [bugfix] #3378

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyro/distributions/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def __init__(
self.transforms = transforms

@constraints.dependent_property(event_dim=2)
def support(self):
def support(self): # noqa: F811
return constraints.independent(self.observation_dist.support, 1)

def expand(self, batch_shape, _instance=None):
Expand Down
2 changes: 1 addition & 1 deletion pyro/distributions/stable_log_prob.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def set_integrator(num_points):

# Stub which is replaced by the default integrator when called for the first time
# if a default integrator has not already been set.
def integrate(*args, **kwargs):
def integrate(*args, **kwargs): # noqa: F811
set_integrator(num_points=501)
return integrate(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion pyro/infer/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _get_type_from_frozenname(frozen_name):

sample_param[name] = [
upstream
for upstream in get_provenance(site["fn"].log_prob(site["value"]))
for upstream in provenance
if upstream != name and _get_type_from_frozenname(upstream) == "param"
]

Expand Down
10 changes: 10 additions & 0 deletions tests/infer/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ def guide(zdim=1, scale=1.0):
scale=scale,
)
assert k > krange[0] and k < krange[1]


def test_render_model_deterministic_param():
def model():
value = pyro.param("param", torch.tensor(0.0))
pyro.deterministic("deterministic", value)

graph = pyro.render_model(model, render_params=True, render_deterministic=True)

assert "\tparam -> deterministic\n" in graph.body
Loading