How to make 2 variables conditional independent

Hello,
this is a very simple question. In the code below a[0] and a[1] will be assumed to be conditionally INDEPENDENT, similarly for b[0] and b[1]. (This is because they live in different slices of the pyro.plate). However b[k] will be assumed to be conditionally DEPENDENT on a[k], for k=0,1. (This is because they live in the same slice of pyro.plate and b follows a). So my question is: How do we declare that a,b are independent?

with pyro.plate("my_plate1", 2):
    a =  sample('a', Bernoulli(0.5))
    b = sample('b',  Normal(0.0,1.0))

It’s a little awkward, but you can use a second plate:

with pyro.plate("my_plate1", 2):
    for i in pyro.plate("my_plate2", 2):
        if i == 0:
            a = pyro.sample('a', Bernoulli(0.5))
        elif i == 1:
            b = pyro.sample('b', Normal(0., 1.))

Ideally dependency tracking at this level of granularity will eventually be done automatically instead of making the user provide such detailed annotation. Also note that some inference algorithms in Pyro (those that exploit parallel enumeration or reparameterized gradient estimators) already have access to finer-grained dependency structure via PyTorch.

1 Like

Thanks for the reply.