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

[discussion] Parameters not rendering when feeding into pyro.deterministic #3371

Closed
KevinTran-TRI opened this issue May 29, 2024 · 1 comment · Fixed by #3378
Closed

[discussion] Parameters not rendering when feeding into pyro.deterministic #3371

KevinTran-TRI opened this issue May 29, 2024 · 1 comment · Fixed by #3378

Comments

@KevinTran-TRI
Copy link

Issue Description

Parts of my programs are deterministic, and these parts still have latent parameters I would like to make inferences of. But when I try to render my program, my registered parameters are not showing up. It looks like this only happens when these parameters are feeding strictly deterministic variables.

I suspect they're not rendering because parameters that feed only into deterministic "variables" will not actually be part of optimization. Is this true?

Environment

  • OS: macOS Sonoma 14.5
  • Python version: 3.11.4
  • PyTorch version: 2.0.0
  • Pyro version: 1.9.0+f02dfb9

Code Snippet

import pyro
import pyro.distributions as dist
import torch


data = torch.tensor([1.0, 2.0, 3.0])

def deterministic_model(data):
    value = pyro.param("param", torch.tensor(0.))
    with pyro.plate("plate", len(data)):
        pyro.deterministic("deterministic", data + value)

pyro.render_model(deterministic_model, model_args=(data,), render_params=True)
def probabilistic_model(data):
    value = pyro.param("param", torch.tensor(0.))
    with pyro.plate("plate", len(data)):
        pyro.sample("probabilistic", dist.Normal(value, 1), obs=data)

pyro.render_model(probabilistic_model, model_args=(data,), render_params=True)
@BenZickel
Copy link
Contributor

Hi @KevinTran-TRI, the behavior you are seeing is a bug only in rendering the model's graph and will be fixed by #3378.

I'm not sure what you are trying to do but the computation is done correctly.

Please note however that deterministic nodes are used mainly for recording values which are completely determined by their parents and they do not affect the model probability density and cannot be observed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants