I was going through the example but I am facing trouble understanding how the below function works.
def ll_docs_f(docs):
dixs, vixs = docs.nonzero()
vfreqs = docs[dixs, vixs]
ll_docs = vfreqs * pmmath.logsumexp(
tt.log(theta[dixs]) + tt.log(beta.T[vixs]), axis=1).ravel()
# Per-word log-likelihood times num of tokens in the whole dataset
return tt.sum(ll_docs) / (tt.sum(vfreqs)+1e-9) * n_tokens
Because the dimensions of theta and beta.T will not be the same so there should be a dimension mismatch error. I am not using the same case and dataset as they are in the example but creating a dummy data for my implementation of ADVI on the model using
with model:
theta = pm.Dirichlet("thetas", a=alpha, shape=(D, K))
phi = pm.Dirichlet("phis", a=beta, shape=(K, V))
doc = pm.DensityDist('doc', log_lda(theta,phi), observed=data)
def log_lda(theta,phi):
ll = pm.math.logsumexp(t.log(theta) + t.log(phi.T), axis =1)
return ll
I get an error:
ValueError: Input dimension mis-match. (input[0].shape[0] = 3, input[1].shape[0] = 2)
Any insight would be helpful. Thanks.