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

Render deterministic functions of random variables #3134

Closed
Eric-Bradford opened this issue Sep 6, 2022 · 9 comments · Fixed by #3266
Closed

Render deterministic functions of random variables #3134

Eric-Bradford opened this issue Sep 6, 2022 · 9 comments · Fixed by #3266
Labels
enhancement help wanted Issues suitable for, and inviting external contributions

Comments

@Eric-Bradford
Copy link

Eric-Bradford commented Sep 6, 2022

I would like to show variables explicitly using "render_model" that are functions of other variables. I tried using "deterministic" or "Delta distribution" for this purpose, but this seems to not propagate like other distributions, e.g.

def model(data):
    m = pyro.sample("m", dist.Normal(0, 1))
    sd = pyro.sample("sd", dist.Delta(m**2))
    with pyro.plate("N", len(data)):
        pyro.sample("obs", dist.Normal(m, sd), obs=data)
data = torch.ones(10)
pyro.render_model(model, model_args=(data,))

image

If I define sd as a normal distribution it shows the connection between sd and obs correctly, but with "Delta" the connection is not shown. How can I define sd as a function of m that would show this connection?

@fritzo fritzo added the bug label Sep 6, 2022
@fritzo
Copy link
Member

fritzo commented Sep 6, 2022

Hi @Eric-Bradford this looks like a bug to me, let me take a look at what might be causing it...

@Eric-Bradford
Copy link
Author

Hi @fritzo, that would be great thanks!

@fritzo
Copy link
Member

fritzo commented Sep 8, 2022

OK, this is not a bug, merely a historical design choice (pyro.infer.inspect originated as an inference tool that was concerned with only latent variables, hence it ignored deterministic dependencies). I've started sketching support for this feature in a branch but it's a little more complex than I expected due to low-level provenance tracking issues. Working on it...

@fritzo
Copy link
Member

fritzo commented Jan 7, 2023

See also this forum discussion

@fritzo fritzo changed the title Render functions of random variables Render deterministic functions of random variables May 23, 2023
@fritzo fritzo added the help wanted Issues suitable for, and inviting external contributions label May 23, 2023
@r3v1
Copy link
Contributor

r3v1 commented Jul 27, 2023

Have been any advances on this?

@fehiepsi fehiepsi reopened this Jul 27, 2023
@fritzo
Copy link
Member

fritzo commented Jul 28, 2023

I believe there has been no progress, but @eb8680 was looking into it around 6 months ago.

@r3v1
Copy link
Contributor

r3v1 commented Aug 7, 2023

Is there any plan to implement this in the short time? I've tried patching it somehow but I got lost...

@eb8680
Copy link
Member

eb8680 commented Aug 7, 2023

@r3v1 no, sorry, it's unlikely I/we will have the bandwidth to fix this ourselves any time soon. You're welcome to play around with the branch linked above and see if you can get it working yourself.

@r3v1
Copy link
Contributor

r3v1 commented Aug 7, 2023

Thanks anyway. I tried but it was quite difficult for me to understand what is going on behind the scenes, I would take it more deeply if I had some documentation, by the way, do you have any resources about?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted Issues suitable for, and inviting external contributions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants