Hello @junpenglao,
Thanks for your response and advice!
The shapes of the variables within the steps above are:
- Dirichlet sample of class probabilities
[1,] - Sample of class labels t
[I,]
Hyper parameter lambda[J, J] - Sample of alpha
[K, J, J] - Confusion matrices sample
[K, J, J] - Class labels generated by classifiers
[I, K]
I suppose using the T.tensor.stack([]) function the code would look like this:
IBCC = pm.Model()
with IBCC:
p_vec = pm.Dirichlet(name='p_vec', a=nu_vec)
t = pm.Categorical(name='t', p=p_vec, shape=I)
alpha = [pm.Exponential('alpha_{}'.format(k), lam=lambda_mat, shape=(J, J)) for k in range(K)]
alpha = T.tensor.stack(alpha)
pi = [[pm.Dirichlet('pi_j{}k{}'.format(j, k), a=alpha[k][j], shape=3) for j in range(J)] for k in range(K)]
pi = T.tensor.stack(pi)
c = [[] for k in range(K)]
t_sample = t.random()
for i in range(I):
for k in range(K):
c[k].append(pm.Categorical('c_k{}i{}'.format(k, i), p=pi[k][t_sample[i]], observed=c_train[k][i]))
c = T.tensor.stack(c)