Side effects of gaussian prior on Variational AE latent variables

matheo_r: <p>Hi everyone,</p>
<p>I had some thoughts on the gaussian prior on VAE latent variables. For instance, Kingma et al. in the original paper (<a href="https://arxiv.org/abs/1312.6114" class="inline-onebox" rel="noopener nofollow ugc">[1312.6114] Auto-Encoding Variational Bayes</a>) illustrated the manifold learned on MNIST data by a VAE with 2 latent variables.</p>
<p>Let’s say for the sake of the argument that images whose latent variables are around (0,0) are images of 3. The gaussian prior being centered at zero, 3 images will be more likely to be generated than sixes or tens…</p>
<p>If I understand it right, this is clearly an unwanted side effect of the gaussian priors.</p>
<p>Does anyone have an opinion on this ?</p>
<p>Thanks,<br>
Happy Christmas all,<br>
Matheo</p>

googlebot: <p>I think you wouldn’t normally sample from prior, beyond some diagnostic plots (even then, note that paper you linked uses quantiles for that plot). So, yeah, posterior clusters are scattered around zero randomly, but encoder deals with that.</p>

matheo_r: <p>Hi <a class="mention" href="/u/googlebot">@googlebot</a>  thanks for the reply although it seems (from some papers and from this topic: <a href="https://stats.stackexchange.com/questions/369660/when-generating-samples-using-variational-autoencoder-we-decode-samples-from-n" class="inline-onebox" rel="noopener nofollow ugc">machine learning - When generating samples using variational autoencoder, we decode samples from $N(0,1)$ instead of $\mu + \sigma N(0,1)$ - Cross Validated</a>) that sampling from the prior is the usual way.</p>
<p>I have another interrogation that is related to the first one: I have trained a conditional 2-latent variables VAE on MNIST dataset. The generated images are very convincing.  When plotting the latent representations of the generated samples (see figure below), I expected to see clusters which is not the case at all. This is actually what you said :</p>
<blockquote>
<p>So, yeah, posterior clusters are scattered around zero randomly, but encoder deals with that.</p>
</blockquote>
<p>Each color is related to a different number. X and Y axis are the two dimensional latent variables.</p>
<p>I’m quite puzzled, there’s obviously something I don’t get… I thought that small variations of latent variables would induce small variations in generated images as it is presented in Kingma paper on MNIST and Frey Face datasets.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/f/7f93de307401b5bfd5696b5d6e01a27bce7a776e.png" data-download-href="https://discuss.pytorch.org/uploads/default/7f93de307401b5bfd5696b5d6e01a27bce7a776e" title="latent_variables_mnist"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/f/7f93de307401b5bfd5696b5d6e01a27bce7a776e_2_690x364.png" alt="latent_variables_mnist" data-base62-sha1="icBrxXHzmzBQPupeBJtGLLQO67k" width="690" height="364" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/f/7f93de307401b5bfd5696b5d6e01a27bce7a776e_2_690x364.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/f/7f93de307401b5bfd5696b5d6e01a27bce7a776e_2_1035x546.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/f/7f93de307401b5bfd5696b5d6e01a27bce7a776e_2_1380x728.png 2x" data-dominant-color="FDFDFD"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">latent_variables_mnist</span><span class="informations">1848×977 29.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>What do you mean by :</p>
<blockquote>
<p>note that paper you linked uses quantiles for that plot</p>
</blockquote>
<p>The paper says:</p>
<blockquote>
<p>since the prior of the latent space is Gaussian, linearly spaced coor-dinates on the unit square were transformed through the inverse CDF of the Gaussian to produce values of the latent variablesz. For each of these values z, we plotted the corresponding generative pθ(x|z)with the learned parameters θ</p>
</blockquote>
<p>which I don’t understand.</p>

googlebot: <p>You’d sample from prior if you don’t care which digit you generate.</p>
<p>Basically, clusters should overlap at zero. Your picture has too few points too infer contours. Should look like there: <a href="https://stats.stackexchange.com/questions/333018/how-well-does-qzx-match-n0-i-in-variational-autoencoders?rq=1" class="inline-onebox" rel="noopener nofollow ugc">How well does $Q(z|X)$ match $N(0,I)$ in variational autoencoders? - Cross Validated</a></p>
<p>Re: quantiles, I just mean they didn’t use usual sampling or gaussian density, inverse CDF skews axes.</p>

matheo_r: <p>Ok thanks,  it gets clearer!</p>