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

Allow rendering of semisupervised models #3159

Merged
merged 3 commits into from
Dec 2, 2022
Merged

Conversation

fritzo
Copy link
Member

@fritzo fritzo commented Nov 24, 2022

Addresses this forum post

This uses color gradients. It doesn't look perfect, but it's a good first pass. For example:

def model(x, y=None):
    with pyro.plate("N", 2):
        z = pyro.sample("z", dist.Normal(0, 1))
        y = pyro.sample("y", dist.Normal(0, 1), obs=y)
        pyro.sample("x", dist.Normal(y + z, 1), obs=x)

pyro.render_model(
    model,
    model_kwargs=[
        {"x": torch.zeros(2)},
        {"x": torch.zeros(2), "y": torch.zeros(2)},
    ]
)

image

Tested

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@fritzo fritzo requested a review from fehiepsi November 24, 2022 15:49
@fehiepsi
Copy link
Member

This looks pretty cool!! I'll take a pass soon

for thing in things:
for key, value in thing.items():
if key not in result:
result[key] = _deep_merge([t[key] for t in things])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is a little bit complicated to follow so it would be nice to add a test for _deep_merge.

Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Fritz!

@fehiepsi fehiepsi merged commit 6d61ea9 into dev Dec 2, 2022
@fritzo fritzo deleted the render-semisupervised branch January 5, 2023 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants