I’d like to create a Dirichlet Process Mixture Model, where each mixture component is a Multivariate Normal distribution with means drawn from an isotropic prior. However, I’m running into an error that I don’t understand.
The error is: Input dimension mis-match. (input[0].shape[1] = 13, input[1].shape[1] = 2)
My code is:
num_obs, obs_dim = observations.shape
max_num_clusters = 13
def stick_breaking(beta):
portion_remaining = tt.concatenate([[1], tt.extra_ops.cumprod(1 - beta)[:-1]])
return beta * portion_remaining
with pm.Model() as model:
w = pm.Deterministic("w", stick_breaking(beta))
cluster_means = pm.MvNormal(f'cluster_means',
mu=pm.floatX(np.zeros(obs_dim)),
cov=pm.floatX(gaussian_mean_prior_cov_scaling * np.eye(obs_dim)),
shape=(max_num_clusters, obs_dim))
comp_dists = pm.MvNormal.dist(mu=cluster_means,
cov=gaussian_cov_scaling * np.eye(obs_dim),
shape=(max_num_clusters, obs_dim))
obs = pm.Mixture(
"obs",
w=w,
comp_dists=comp_dists,
observed=observations,
shape=obs_dim)
Can someone clarify how to get my shapes to work properly?
I posted on StackOverflow (pymc - PyMC3 Dirichlet Process Multivariate Gaussian Mixture Model - Stack Overflow) but hopefully posting here gets me a faster answer.