On plates and dimension independence

Hello,
I am just having some trouble understanding what exactly we mean when we say that plates specify independence among some dimension. For example, if I have the code
x_axis = pyro.plate('x_axis', width, dim=-2)
What does it precisely mean mathematically that we have independence along the -2 dimension? Does it mean that if I sample some “matrix” x then, the submatrices x[..., i, :] (with i having any admissible value) will be independent?
Thank you

That’s right, any pyro.sample() statements inside your plate(..., dim=-2) context will be conditionally independent along the -2 axis. The “conditional” part means that there can be dependence introduced if the parameters of those sample statements depend on a common upstream random variable outside of the plate. For example in this first model the random variables “loc” are completely independent:

def model_1(data):
    with pyro.plate("x_axis", data.size(-2), dim=-2):
        with pyro.plate("y_axis", data.size(-1), dim=-1):
            pyro.sample("scale", dist.LogNormal(0, 1))
            pyro.sample("loc", dist.Normal(0, scale))
            pyro.sample("obs", dist.Normal(loc, 1),
                        obs=data)

whereas in this second model the “loc” are only independent conditioned on “scale”, so we say they are conditionally independent along the “y_axis” but completely independent along the “x_axis”.

def model_2(data):
    with pyro.plate("x_axis", data.size(-2), dim=-2):
        pyro.sample("scale", dist.LogNormal(0, 1))
        with pyro.plate("y_axis", data.size(-1), dim=-1):
            pyro.sample("loc", dist.Normal(0, scale))
            pyro.sample("obs", dist.Normal(loc, 1),
                        obs=data)
2 Likes

Thank you. I understand now!