Could you give me some advice about this modle?


I want to build a Dirichlet process mixture model based on beta distribution. But there are some problems, who can give some advice?

here is my code:

def stick_breaking(beta):
portion_remaining = tt.concatenate([[1], tt.extra_ops.cumprod(1 - beta)[:-1]])
return beta * portion_remaining

K = 10
pm Model() as model:
    alpha = pm.Gamma('alpha', 1., 1.)
    beta = pm.Beta('beta', 1., alpha, shape=K)
    w = pm.Deterministic('w', stick_breaking(beta))
    Phi = []
    Delte = []
    aj = []
    Mu = []
    Eta = []
    bj = []
    comp_dist = []
    for i in range(K):
        Phi.append(pm.InverseGamma('Phi%i'%i, alpha=1, beta=1))
        Delte.append(pm.Exponential('Delte%i'%i, lam=1/4))
        aj.append(pm.InverseGamma('aj%i'%i, alpha=Phi[i], beta=Delte[i], shape=2))
        Mu.append(pm.InverseGamma('Mu%i'%i, alpha=1, beta=1))
        Eta.append(pm.Uniform('Eta%i'%i, lower=0.0, upper=1.0))
        bj.append(bj = pm.Beta('bj%i'%i, alpha=Mu[i]*Eta[i], beta=Mu[i]*(1-Eta[i]), shape=2))
        comp_dist.append(pm.Beta.dist(alpha=aj[i], beta=bj[i], shape=2))
    x_obs = pm.Mixture('x_obs', w, com_dist, observed=X)
    trace = pm.sample(2000, tune=1000, chains=1)

error is:

ValueError: Input dimension mis-match. (input[0].shape[2] = 7, input[1].shape[2] = 2)

This is duplicate with Could you help me with dirichlet process mixture model´╝č. I will close this post.