Setting multiple times hidden variable using pyro.condition

Hi everybody,

I’m reading about pyro.condition and according to the Pyro documents. According to the docs you can constrain a single site only once.

def scale2(guess):
    weight = pyro.sample("weight", dist.Normal(guess, 1.))
    tolerance = torch.abs(pyro.sample("tolerance", dist.Normal(0., 1.)))
    return pyro.sample("measurement", dist.Normal(weight, tolerance))

# define model, intentionlly set weight twice
conditioned_scale_repeat = pyro.condition(pyro.condition(scale2, data={'weight': 9, 'weight':11}),
                                          data={'weight':10})
posterior_repeat = pyro.infer.Importance(conditioned_scale_repeat, num_samples=100)


# perform some inferences
guess = 8.55
marginal = pyro.infer.EmpiricalMarginal(posterior.run(guess))
print(marginal())

So in the above code, I set “weight” three times using pyro.condition. And there was no error raised. Did I understand the docs incorrectly?

Sorry my bad. I use the wrong posterior object.