Hello,

I am a novice with PPL in general and Pyro in particular. I have a very simple model that I am trying to write in Pyro but can’t wrap my head around it.

For context, I have a set of 134 objects, 17 contexts and 17 evaluators.

I have surveyed the evaluators which answered yes/no/unknown to the questions “is object i suitable in context j?” and now I want to model the data and make some inferences.

The model I am considering is pretty straightforward: I am considering a hidden binary z_{ij} variable for each pair (\textrm{object}_i, \textrm{context}_j) which is the true answer to the question “is object i suitable in context j?”, and it is distributed as a \textrm{Bernoulli} variable with parameter p_{ij}. In addition, I have a parameter \alpha_k associated to each evaluator (measuring the expertise or the “adversarialness” of the evaluator) and a parameter \beta_j which models the “difficulty” of each context. I collected each answer in a list y_{ijk} and I am modeling the likelihood of y_{ijk} being 1 as p(y_{ijk}=1|z_{ij}) = \sigma(\alpha_k * \beta_j)^{z_{ij}} \times (1-\sigma(\alpha_k * \beta_j))^{(1-z_{ij})}, where \sigma is the sigmoid function.

This is how I implemented it:

```
@config_enumerate
def model(object, context, evaluator, y=None):
n_samples, n_objects, n_contexts, n_evaluators = (
len(object),
object.max().item() + 1,
context.max().item() + 1,
evaluator.max().item() + 1,
)
expertise = pyro.param("expertise", torch.zeros(n_evaluators))
difficulty = pyro.param("difficulty", torch.ones(n_contexts), constraint=constraints.positive)
p = pyro.param("p", torch.ones(n_objects, n_contexts) * 0.5, constraint=constraints.unit_interval)
with pyro.plate("object", size=n_objects, dim=-3):
with pyro.plate("context", size=n_contexts, dim=-2):
hidden_label = pyro.sample("hidden_label", dist.Bernoulli(p))
with pyro.plate("data", size=n_samples) as k:
e = expertise[evaluator[k]]
diff = difficulty[context[k]]
z = Vindex(hidden_label)[object[k], context[k]]
sigma = torch.sigmoid(e * diff)
pyro.sample("obs", dist.Bernoulli(probs=(sigma ** z) * ((1-sigma)**(1-z))), obs=y[k])
```

When I try to run it, I get the error “IndexError: index 100 is out of bounds for dimension 0 with size 2” on the line in which I assign the value to z. I understood that this is likely due to the enumeration taking place along the first dimension.

What would be the correct way of doing this?