Error while using DensityDist

How does DensityDist function work in pymc3? When I am trying to print the shape of the observed data it prints twice? Why does it happen? Shouldn’t it print only once. Basically my doubt is how does this function work with its parameters?

with model:
    pi_list = pm.Dirichlet('userx_pi', a=alpha, shape = (people, K))
    z_aTb = pm.Categorical('a_' ,p = pi_list, shape =(people,people))
    y = pm.DensityDist('dist' ,ll_mmsb(z_aTb,pi_list), observed = user_data)

def ll_mmsb(z_aTb,pi_list):
    def log_mmsb(value):
    return log_mmsb

Also I am getting this error which I am not able to trace for DensityDist. I think it might be because of the z_aTb RV.

AsTensorError: (‘Cannot convert None to TensorType’, <class ‘NoneType’>)

How can I use z_aTb in DensityDist for further calculating likelihood for ADVI?
Help much needed.


The twice printing might due to the way you write down the logp, where it first initialize as a function, and then the function get evaluated.
Did you have a look at How to set up a custom likelihood function for two variables ? It might clear some of your confusion.