I’m trying to implement some type of a mixture model with multiple components, thus want to use sampling over a categorical variable to devide the data points into clusters randomly. However, when I try to sample
dist.Categorial through MCMC, even without any observations, the sample sizes suddenly changes on the second sample. The following code reproduces it.
What am I doing wrong? Should I approach this differently?
Note that just using
dist.Categorical outside any model works fine.
import pyro import pyro.distributions as dist from pyro.infer.mcmc.api import HMC, MCMC, NUTS def model(): classes = pyro.sample("classes",dist.Bernoulli(torch.tensor([[0.3,0.7], [0.3,0.7],[0.3,0.7], [0.3,0.7],[0.3,0.7], [0.3,0.7],[0.3,0.7], [0.3,0.7]]))) print(classes.shape) mcmc = MCMC(HMC(model, target_accept_prob=0.8), num_samples=10, warmup_steps=10, num_chains=1) mcmc.run()