Skip to content

Graphviz does not properly show observed ConstantData when subjected to intermediate Ops #5795

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

Closed
larryshamalama opened this issue May 24, 2022 · 5 comments · Fixed by #6011
Labels

Comments

@larryshamalama
Copy link
Member

larryshamalama commented May 24, 2022

with pm.Model() as model:
    data = pm.ConstantData("data", [0, 0, 1, 1], dtype=np.int64)
    p = pm.Beta("p", 1, 1)
    bern = pm.Bernoulli("response", p, observed=data)
    
pm.model_to_graphviz(model)

yields

image

In other words, there should be an arrow from response to data. This is because model["data"].tag.observations is in fact an Elemwise operation rather than data as defined under the context manager. I don't think that this was broken from the recently merged PR #5634.

@ricardoV94
Copy link
Member

I don't know the internals of model_graph, but one thing worth noting is that data only exists in the logp graph (as do other elements like potentials).

@larryshamalama
Copy link
Member Author

larryshamalama commented May 24, 2022

On my end, I'm not as familiar with the internals of the initialization of the logp graph under a pm.Model(), but the observed nodes in graphviz are obtained by checking observed_rv.tag.observations as per this line.

@drbenvincent
Copy link

not 100% sure, but this is cropping up quite a bit. Eg
Screenshot 2022-07-14 at 10 47 42
(from here https://www.pymc.io/projects/examples/en/latest/causal_inference/excess_deaths.html)

Personally, I think this is a relatively high priority defect

@larryshamalama
Copy link
Member Author

Can try to have a closer look before the weekend. Thanks for sharing!

@larryshamalama
Copy link
Member Author

not 100% sure, but this is cropping up quite a bit. Eg Screenshot 2022-07-14 at 10 47 42 (from here https://www.pymc.io/projects/examples/en/latest/causal_inference/excess_deaths.html)

Personally, I think this is a relatively high priority defect

I will submit a PR that would close this issue, but I am doubtful that it would fix this problem (which should be very fixable). I will investigate further soon.

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