I am working on a generative model on Bernoulli Mixture model. I came up with a model but I have trouble using my data in sparse form while calculating log-likelihood.
with dir_model: pi = pm.Dirichlet('pi', a = np.ones(K), shape = K) dri = pm.Dirichlet('dri', a = np.ones((K, B)), shape = (K, B)) vector_U = pm.DensityDist('vec_u', ll_bern(dri, pi), observed = observed_d) def ll_bern(dri, pi): def logp_(value): logps = [tt.log(pi[i]) + tt.sum(tt.log(value*dri[i,:] + (1-value)*(1 - dri[i,:])),axis=1) for i in range(K)] return tt.sum(logsumexp(tt.stacklists(logps)[:, :value.shape], axis=0)) return logp_
observed_d is the data in csr sparse format. The model works fine without sparse on a synthetic dataset but with original dataset I have to make it somehow work with sparse because of its large nature.
Help much appreciated.