
What tutorial are you running? Inference with Discrete Latent Variables

What version of Pyro are you using? 0.3

Please link or paste relevant code, and steps to reproduce.
serving_model = infer_discrete(model, first_available_dim=1)
x, y, z = serving_model() # takes the same args as model(), here no args
print(“x = {}”.format(x))
print(“y = {}”.format(y))
print(“z = {}”.format(z))
I have no issue with reproducibility, but I do not understand when to use infer_discrete. There is very little written on this function. What does it actually do? What happens if one specifies parallel enumeration without using infer_discrete?
In the tutorial, this function is used when working with multiple latent variables. Why only then?
The following code enumerates without using discrete_infer. If possible, I would like to see a use case that uses discrete_infer that makes it clear why it is needed.
def model():
z = pyro.sample("z", dist.Categorical(torch.ones(5)))
print('model z = {}'.format(z))
def guide():
z = pyro.sample("z", dist.Categorical(torch.ones(5)))
print('guide z = {}'.format(z))
elbo = Trace_ELBO()
elbo.loss(model, guide);