I am trying to specify priors on a kernel that is being used in a GP as a submodel of a larger model. The kernel is specified in a plate as follows:

```
with pyro.plate("venues", V):
K_v = gp.kernels.Sum(
gp.kernels.Matern32(
input_dim=1,
lengthscale=torch.tensor(4.),
variance=torch.tensor(1.)
),
gp.kernels.RBF(
input_dim=1,
lengthscale=torch.tensor(15.),
variance=torch.tensor(1.)
)
)
```

I can set the lenghtscale priors as follows:

```
K_v.kern0.set_prior(
"lengthscale",
Uniform(torch.tensor(5.0), torch.tensor(10.0))
)
K_v.kern1.set_prior(
"lengthscale",
Uniform(torch.tensor(10.0), torch.tensor(20.0))
)
```

and the model fits with SVI without error.

However, when I try to do the same for the variance:

```
K_v.kern0.set_prior(
"variance",
Gamma(torch.tensor(2.0), torch.tensor(0.5))
)
K_v.kern1.set_prior(
"variance",
Gamma(torch.tensor(2.0), torch.tensor(0.5))
)
```

I get a RuntimeError that complains about its shape:

```
~/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/pyro/contrib/gp/kernels/isotropic.py in forward(self, X, Z, diag)
148 r = self._scaled_dist(X, Z)
149 sqrt3_r = 3**0.5 * r
--> 150 return self.variance * (1 + sqrt3_r) * torch.exp(-sqrt3_r)
151
152
RuntimeError: The size of tensor a (211) must match the size of tensor b (252) at non-singleton dimension 1
Trace Shapes:
Param Sites:
Sample Sites:
m_mu dist |
value |
s_mu dist |
value |
mu dist 4207 |
value 4207 |
lengthscale dist 13 |
value 13 |
f_tilde dist 252 13 |
value 252 13 |
noise dist |
value |
beta dist | 252 13
value | 252 13
kern0.variance dist 211 |
value 211 |
Trace Shapes:
Param Sites:
Sample Sites:
```

This is confusing because a) its a scalar prior, so I expect it to work irrespective of the shapes of other things and b) lenghtscale prior setting works just fine.

I have tried adding `.to_event()`

to the priors, but this does not resolve the problem.

Any ideas?