I am trying to compute the posterior p(z|x) for this very simple model, and for some reason I do not understand what I am doing wrong (I am discovering this package). Generating data from this model seems to be working, MCMC sampling won’t work.
Here is my model:
def pyro_mdl(data): # with pyro.plate('data', len(data)): cell_type = pyro.sample('cell_type', dist.Categorical(dataset.probas)) z = pyro.sample('z', pyro.distributions.MultivariateNormal(dataset.mus[cell_type], dataset.sigmas[cell_type])) exp_z = z.exp() x = pyro.sample('x', pyro.distributions.Poisson(rate=exp_z), obs=data) return x
The parameters have already been fitted (I am mostly interested in MCMC right now). When I try to perform MCMC using:
kernel = HMC(pyro_mdl, adapt_step_size=True, jit_compile=True, ) mcmc_run = MCMC(kernel, num_samples=500, warmup_steps=300).run(data=x)
I get the following error! “TypeError: only integer tensors of a single element can be converted to an index”
Do you have an idea what I have been doing wrong?