I have a model that implements a latent GP as follows (relevant code shown), which later gets indexed appropriately and added into the rest of the model:
class MyModel(PyroModule); def __init__(self): ... self.K = gp.kernels.RBF(input_dim=1, variance=self.amp, lengthscale=self.ls) cov_beta = self.K(torch.DoubleTensor(days).to(device)) cov_beta.view(-1)[:: self.game_days.shape + 1] += jitter self.Lff_beta = cov_beta.cholesky().detach() ... def forward(self, X, y): ... f = pyro.sample("f", MultivariateNormal( torch.zeros_like(self.all_days).to(device), scale_tril=self.Lff_beta )) ... theta = mu[player_index] theta += f[day_index] theta += g[venue_index, day_index] ...
This model fits just fine using SVI, but when I later go to predict (Note that
data is the same that is used to fit the model (the last element is the response data
y, so it is left out of the predict):
predictive = pyro.infer.Predictive(model, guide=guide, num_samples=1000, return_sites=("f",)) samples = predictive(*data[:-1])
the call to
524 # Expected value 525 theta = mu[player_index] --> 526 theta += f[day_index] 527 theta += g[venue_index, day_index] IndexError: index 90 is out of bounds for dimension 0 with size 1
It seems like something different is happening to the shape of the MutlivariateNormal when using
Predictive. Is this true, or am I doing something wrong?