I have a Pyro model that I have fit using SVI that, among other components, includes the following:
with pyro.plate('year_effect', len(seasons)-1):
gamma = pyro.sample('gamma', Normal(loc=dtensor(0.), scale=dtensor(10.)))
_gamma = torch.cat([dtensor([0.]), gamma])
(dtensor
is just my own convenience function for creating a tensor on the CUDA device)
Though the model is fit without error, when I try to sample from the model via pyro.infer.Predictive
, I get a failure at this point in the model.
RuntimeError Traceback (most recent call last)
<ipython-input-26-ba8d4e5a9b46> in ra_model(age_idx, pitcher_idx, season_idx, stuff_data, command_data, dN_data, n_data, r_data)
72 with pyro.plate('year_effect', len(seasons)-1):
73 gamma = pyro.sample('gamma', Normal(loc=dtensor(0.), scale=dtensor(10.)))
---> 74 _gamma = torch.cat([dtensor([0.]), gamma])
75
76
RuntimeError: Tensors must have same number of dimensions: got 1 and 2
Is there any obvious reason why a dimension would be added to gamma
after it is fit? This is clearly a 1-dimensional tensor as specified in the plate.