Difference between Normal and MultiVariateNormal distributions in Pytorch


I have a bit of misunderstanding regarding the difference between the Normal distribution and the MultiVariateNormal distribution in pytorch. As I understand it, Normal distribution are univariate and so loc and scale should be floats. However, it is possible to define Normal distribution with vector mean and vector covariance which is in this case a multivariate gaussian right ? So in pytorch the following works for instance:

batch_size = 512
dim = 4
mean = torch.rand((batch_size,dim))
log_var = torch.rand(((batch_size,dim))
d = Normal(mean,torch.exp(0.5*log_var))

But in this case I define a multivariate normal using the univariate Normal distribution from pytorch right ? How does pytorch interpret this ?

Please help me clear this misunderstanding

Hi Samuel!

When you do this, you are defining a special case of a multivariate
gaussian distribution where a sample is a vector, and the elements
of that vector are uncorrelated with one another.

That is, the covariance of the distribution is a diagonal matrix whose
diagonal is the square of the vector of standard deviations you passed
into Normal.


K. Frank