AntixK / PyTorch-VAE

A Collection of Variational Autoencoders (VAE) in PyTorch.
Apache License 2.0
6.46k stars 1.05k forks source link

Sampling Vanilla VAE #32

Open ethancohen123 opened 3 years ago

ethancohen123 commented 3 years ago

Hi, First, thanks for all the shared work ! I have a question concerning the sampling function in the Vanilla VAE. Why do you sample from a normal distribution (0,1) and not from a normal distribution with the learned parameters mu and sigma ? Since when we train the network we decode from the latent space over this distribution isnt more meaningful to sample from this distribution ? Maybe is there something I didnt get. Thank you again

iitrsamrat commented 3 years ago

I am not sure ideally it should be scaled like below i think.

mu/var comes out of the encoder network.

final_samples = mu + (sqrt(var) * samples)

lihuiliullh commented 2 years ago

I have the same question. @AntixK

wztdream commented 1 year ago

When you do sampling, it means you did not have "input" images, you only sample from some distribution, here is a standard normal distribution. In other words, when sampling you did not have encoder, only use decoder, so you did not have this mu and var.