Warning error regarding Bernoulli support

Hi,

Consider the following code (Pyro 0.3):

isCorrect1 = pyro.sample("isCorrect1", dist.Bernoulli(.3), obs=torch.tensor(1.))
print(isCorrect1)
print(type(isCorrect1))

the output is

tensor(1.)
<class ‘torch.Tensor’>
/Users/erlebach/anaconda3/lib/python3.7/site-packages/pyro/primitives.py:71: RuntimeWarning: trying to observe a value outside of inference at isCorrect1
RuntimeWarning)

My question is “Why do I get this warning?”. The support of the Bernoulli distribution is 0 and 1 (not clear what type).
Thanks.

Gordon

Why do I get this warning?

A Pyro program with no observations corresponds to a joint probability distribution over the individual random variables in the program. When you use obs= to fix the value of one of those random variables instead of sampling it, an execution of the model no longer corresponds to a sample from that joint distribution (or any normalized probability distribution), and you need to run inference to fix that, which is what the warning is saying.

1 Like