What is the point of renaming the sample function in this tutorial?

The following is from official tutorial

def geometric(p, t=None):
    if t is None:
        t = 0
    x = pyro.sample("x_{}".format(t), pyro.distributions.Bernoulli(p))
    if x.item() == 1:
        return 0
    else:
        return 1 + geometric(p, t + 1)

print(geometric(0.5))

Why they’re renaming the sample function? I tried it without renaming and it is working fine

that’s because the model is just being run forwards. if you use it to do inference, your sample sites need to have unique names.

1 Like

Thanks. I recommend adding this to the documentation on the first page, it is illuminating.