Hello everyone,
I am new to probabilistic programming and am currently working with the Gaussian process latent variable model (gplvm) as outlined in the link below.
http://docs.pyro.ai/en/0.2.1-release/_modules/pyro/contrib/gp/models/gplvm.html
However the problem with this model is that is does not support mini batching with large data sets. I went through the SVI tutorial part 2 but am having a little trouble adding mini batching in the current implementation to scale it up to large data sets. How do i incorporate the following lines used for SVI part 2 in the model and the guide?
for i in pyro.irange("data_loop", len(data), subsample_size=self.batch_size):
pyro.sample("obs_{}".format(i), dist.MultivariateNormal(X_loc[i],X_scale_tril[i]), obs=data[i])
If data is a 150 x 4 tensor how should i sample mini batch of this high dimensional data in the above statement and how to incorporate it in the model and guide. Any help on this would be appreciated.
def model(self):
self.set_mode(“model”, recursive=False)
# sample X from unit multivariate normal distribution
zero_loc = self.X_loc.new_zeros(self.X_loc.shape)
C = self.X_loc.shape[1]
Id = torch.eye(C, out=self.X_loc.new_empty(C, C))
X_name = param_with_module_name(self.name, "X")
X = pyro.sample(X_name, dist.MultivariateNormal(zero_loc, scale_tril=Id)
.independent(zero_loc.dim()-1))
self.base_model.set_data(X, self.y)
self.base_model.model()
def guide(self):
self.set_mode(“guide”, recursive=False)
# sample X from variational multivariate normal distribution
X_loc = self.get_param("X_loc")
X_scale_tril = self.get_param("X_scale_tril")
X_name = param_with_module_name(self.name, "X")
X = pyro.sample(X_name,
dist.MultivariateNormal(X_loc, scale_tril=X_scale_tril)
.independent(X_loc.dim()-1))
self.base_model.set_data(X, self.y)
if self._call_base_model_guide:
self.base_model.guide()