Closed MCGallaspy closed 8 years ago
The shape isn't inferred for an array of Dirichlets:
import numpy as np
import pymc3 as pm
num_alphas_per_dirichlet = 4
# One Dirichlet
with pm.Model():
alphas = np.ones(num_alphas_per_dirichlet)
p = pm.Dirichlet('p', alphas)
# Three Dirichlets
with pm.Model():
num_dirichlets = 3
alphas = np.ones((num_dirichlets, num_alphas_per_dirichlet))
p = pm.Dirichlet('p', alphas, shape=num_dirichlets)
The second Model throws an error, not inferring the shape of the alpha parameters:
ValueError: operands could not be broadcast together with shapes (3,) (3,4)
Correct, nor does this occur for any multvariate distributions at present. It is something that we have discussed and need to tackle soon. (See #535) Your input is welcome.
On the
master
branch, just downloaded today, the following scriptGives me this error:
By specifying the shape parameter (
theta = pymc3.Dirichlet("theta", np.ones(3), shape=3)
), it works fine. Any reason we can't infer the shape from the parametera
?