I want to use SVI to inference for a multivariate sequence with shape [365,5]. The code can be simplified as:
sigma=pyro.sample(dist.uniform(0,1).expand([5]).to_event(1)) #X[365,5],Y[365,5]
for i in pyro.plate(“data”,X):
…obs=pyro.sample(‘obs_{}’.format(i),dist.Normal(loc=X[:,i],scale=sigma[i]),obs=Y[:,i])
X and Y have a one-year length with 5 features. I gave a different sigma of Normal distribution for each feature. But this setting can not run. I appreciate any help. The error is :
ValueError: at site “obs_0”, invalid log_prob shape
Expected , actual [365]
Try one of the following fixes:
enclose the batched tensor in a with plate(…): context
for i in pyro.plate('time',time_len):
for j in pyro.plate('feature_%d'%(i),feature_len):
y_obs=Y[i,j]
obs=pyro.sample('obs_%d_%d' % (i, j), Normal(loc=X[i, j], scale=sigma[j]),
obs=y_obs)
The error is:
NotImplementedError: AutoGuide does not support sequential pyro.plate
Trace Shapes:
Param Sites:
Sample Sites:
You could try replacing the sequential pyro.plate() with a simple for loop. This should work well as long as all your sample sites are reparameterized.
for i in range(time_len):
for j in range(feature_len):
y_obs=Y[i,j]
obs=pyro.sample('obs_%d_%d' % (i, j), Normal(loc=X[i, j], scale=sigma[j]),
obs=y_obs)