Multivariate Normal Distribution

Dear Pyro Experts

Can anyone help me on this issue? I am constructing a PyroSample with Multivariate Normal which is needed in inference. Here is an example,

gplvm.X = pyro.nn.PyroSample(dist.MultivariateNormal(torch.zeros(3,4), scale_tril=torch.tensor([[1, 0, 0, 0], [1, 1, 0, 0], [0.3, 0, 1, 0], [0.2, 0.1, 0, 1]] )))

The distribution has batch_shape=3 and event_shape = 4. That is good. The object PyroSample is to be called to produce a sample in the shape [3, 4]. That is, three sample of 4 dimensional Gaussian vector.

However inside the inference, it has been assumed that X is in size [4, 3]. How may I produce a distribution which produce a PyroSample in shape [4, 3] where column vectors are independant Gaussian?

Cheers

J

Hi @junbin.gao, I think you can define a PyroSample with shape [3, 4], and in computation, you can swap the dimensions of that pyro sample, like

self.X = PyroSample(...)

# later
X_t = self.X.t()
# then works with X_t instead of self.X

Dear Fehiepsi

Thanks for the suggestion. I will give it a try. I was using
self.X = PyroSample( …)
self.X = self.X.t()
then the sampling keeps unchanged.
J