Closed
Description
What is the intended behavior when passing a 2D array into Categorical?
import pymc3 as pm
with pm.Model():
x = pm.Bernoulli("x", eye(4)[0], shape=4)
tr = pm.sample(10)
tr["x"].mean(0)
Out[30]: array([ 1., 0., 0., 0.])
with pm.Model():
x = pm.Categorical("x", eye(4), shape=4)
tr = pm.sample(10)
tr["x"].mean(0)
Out[35]: array([ 0., 0., 0., 0.])
In [37]: tr["x"].shape
...:
Out[37]: (10, 4)
I was somewhat expecting to see [0, 1, 2, 3], assuming some sort of broadcast.
Also: do others find it alarming that the pymc3 Categorical automatically normalizes the input p vector to sum to 1.0? To me, having an exception on un-normalized input was an important sanity check in pymc2. This would be particularly true if 2D inputs are tolerated, in which case row vs. column normalization is always an issue.
Metadata
Metadata
Assignees
Labels
No labels