-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
Using pymc.dims, using as_tensor is suggested with pymc.dims. However, dims work different with as_xtensor than pmd.<DistributionName>.
import pymc as pm
import pymc.dims as pmd
from pytensor.xtensor import as_xtensor
observed = [5, 7]
coords = {"repo": ["pymc", "pymc-marketing"]}
with pm.Model(coords=coords) as model:
lam = pmd.HalfNormal("lam", dims="repo")
pmd.Exponential(
"obs",
lam=lam,
observed=observed,
dims="repo",
)ValueError: Variable [5, 7] must have dims associated with it.
To avoid subtle bugs, PyMC does not make any assumptions about the dims of parameters.
Use `as_xtensor` with the `dims` keyword argument to specify the dims explicitly.
However, a likely use of as_xtensor doesn't act the way pymc supports dims
observed = as_xtensor([5, 7], dims="repo")
coords = {"repo": ["pymc", "pymc-marketing"]}
with pm.Model(coords=coords) as model:
lam = pmd.HalfNormal("lam", dims="repo")
pmd.Exponential(
"obs",
lam=lam,
observed=observed,
dims="repo",
)
ValueError: Shape (2,) must have the same length as dims ('r', 'e', 'p', 'o')
Metadata
Metadata
Assignees
Labels
No labels