Skip to content

Decide how to handle shape information in logrob derivations #6530

@ricardoV94

Description

@ricardoV94

The behavior of the logprob when the value variable doesn't match shape is exactly the same as the logprob of the underlying components. If it doesn't match, it will try to broadcast and fail if it cannot. Other than that we don't use size information in any of the core logprob functions.

pm.logp(pm.Normal.dist(size=(4,)), np.ones((2,))) will be happy to return a logp with two values.

One other case where this shows up is in graphs of the form pt.ones((5,)) + pm.Normal.dist() which we infer to have an equivalent logp as that of pm.Normal.dist(shape=(5,)) even though the generative process contains only one true random variable, and not 5.

I think we need a bigger discussion about the role of shape information in the random and logp graphs, so I wouldn't treat IfElse differently for now.

Originally discussed in #6529 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions