# Creation of autoguidelist for discrete and continuous variables

I tried to create a guide for a model with discrete and continuous variables and it always gave me the error:
Expected parameter scale (Tensor of shape (20, 20)) of distribution Normal(loc: torch.Size([20, 20]), scale: torch.Size([20, 20])) to satisfy the constraint GreaterThan(lower_bound=0.0), but found invalid values:
tensor([[0., inf, inf, inf, 0., inf, 0., 0., inf, 0., inf, 0., inf, inf, 0., 0., inf, inf, inf, 0.], …

In the model initiation I take a Gamma prior which is close to 0 and then use as standard deviation it to sample over a Normal distribution:
precision1 = pyro.sample(“precision1”, pyro.distributions.Gamma(torch.tensor([10 ** -14]), torch.tensor([10 ** -14])))
scale = pyro.sample(“scale”, pyro.distributions.LogNormal(0., 1./precision1))
pyro.sample(“obs1”, pyro.distributions.Normal(Y1_hat, scale), obs=self.Y1)

Somehow it doesn’t complain when I only use this as a guide:
guide = autoguide.AutoNormal(pyro.poutine.block(self.model, hide=[‘s1’, “s2”]))

but it will start complaining as soon as I use it inside of a list:
guide = autoguide.AutoGuideList(self.model)
guide.append(autoguide.AutoNormal(pyro.poutine.block(self.model, hide=[‘s1’, “s2”])))

Is there a difference in these two?
And can I simply append this line afterwards to add the guides for the discrete variables?

guide.append(autoguide.AutoDiscreteParallel(pyro.poutine.block(self.model, expose=[“s1”, “s2”])))
Thank you very much

1 Like