Question about Restriction 3: single path leaving each plate

  • What tutorial are you running?

Inference with Discrete Latent Variables

  • What version of Pyro are you using?

1.8.1

  • Please link or paste relevant code, and steps to reproduce.

For any enumerated variable x , the set of all enumerated variables on which x depends must be linearly orderable in their vectorized plate nesting.

Could anybody help me understand what linearly orderable means. In the example code, i think that because x and y is defined under different plates, they are orderable by plate dim?

@config_enumerate
def invalid_model(data):
plate_1 = pyro.plate(“plate_1”, 10, dim=-1) # vectorized
plate_2 = pyro.plate(“plate_2”, 10, dim=-2) # vectorized
with plate_1:
x = pyro.sample(“y”, dist.Bernoulli(0.5))
with plate_2:
y = pyro.sample(“x”, dist.Bernoulli(0.5))
with plate_1, plate2:
z = pyro.sample(“z”, dist.Bernoulli((1. + x + y) / 4.))

I found the definition of a linearly ordered set here. My understanding is that here we are comparing the sets of plates themselves ({plate_1} fo x and {plate_2} for y) not their dimensions. Since it is not possible to compare {plate_1} and {plate_2} this breaks the Comparability property in the definition of a linearly ordered set.

For any enumerated variable x , the set of all enumerated variables on which x depends must be linearly orderable in their vectorized plate nesting

Still confused.
I tried the model myself, and found that when i remove variable z’s plate, the code didn’t raise exception. This means that at least the above paragraph might need some modification?

Which part do you find confusing?

Can you provide a reproducible code example of this?
Removing plates for variable z would also violate Restriction 2 I believe.

Would you please give a small example of linearly oderable case, this may delineate this restriction more clearly.

By the way,
Would you please take a look at my question about the second restriction?

Thanks

Example 1

with plate1:
    x = pyro.sample("x", ...)   # enumerated
    with plate2:
        y = pyro.sample("y", ...)   # enumerated
        z = pyro.sample("z", dist.Bernoulli((1. + x + y) / 4.))

Here z depends on x (nested in {plate1}) and y (nested in {plate1, plate2}) enumerated variables. {plate1} is a subset of {plate1,plate2} so we can order them: {plate1} =< {plate1,plate2}.

Example 2

with plate1:
    x = pyro.sample("x", ...)   # enumerated
    y = pyro.sample("y", ...)   # enumerated
    with plate2:
        z = pyro.sample("z", dist.Bernoulli((1. + x + y) / 4.))

Here z depends on x (nested in {plate1}) and y (nested in {plate1}) enumerated variables. {plate1} is equal to {plate1} so we can order them: {plate1} = {plate1}.

Thanks! These examples are really enlightening, would you mind if i copy them to make a pull request to change the current tutorial?

Yeah, you can use these examples if you want.

I’ll have a closer look at the question about the second restriction a bit later.