# Multivariate Gaussian Variational Autoencoder (the decoder part)

**URL:** <https://discuss.pytorch.org/t/multivariate-gaussian-variational-autoencoder-the-decoder-part/58235>\
**Category:** vision\
**Created:** [October 15, 2019, 2:59am UTC](https://discuss.pytorch.org/t/multivariate-gaussian-variational-autoencoder-the-decoder-part/58235 "2019-10-15T02:59:26Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![muammar](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/muammar/32/76367_2.png) [@muammar](https://discuss.pytorch.org/u/muammar)\
**Post date:** [October 15, 2019, 6:37pm UTC](https://discuss.pytorch.org/t/multivariate-gaussian-variational-autoencoder-the-decoder-part/58235/5 "2019-10-15T18:37:06Z")

</div>

> [@tom](#):
>
> You are right about logvar instead of sigma, but there should be no recon\_x. Instead, the recon loss is the neg log likelihood of x under the normal dist given by mu, logsigma with independent elements.

You refer to something like what is shown here: [Backward for negative log likelihood loss of MultivariateNormal (in distributions) - #2 by fritzo](https://discuss.pytorch.org/t/backward-for-negative-log-likelihood-loss-of-multivariatenormal-in-distributions/15339/2).

```auto
n = some_int
mu = torch.zeros(n)
C = torch.eye(n, n)
m = torch.distributions.MultivariateNormal(mu, covariance_matrix=C)
x = m.sample() # should have shape (n,)
loss = -m.log_prob(x) # should be a scalar

```

---

_[View the full topic](https://discuss.pytorch.org/t/multivariate-gaussian-variational-autoencoder-the-decoder-part/58235)._
