Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is noise in GaussianVAE2D a torch Variable? #37

Closed
hsm207 opened this issue Jan 11, 2018 · 1 comment
Closed

Why is noise in GaussianVAE2D a torch Variable? #37

hsm207 opened this issue Jan 11, 2018 · 1 comment

Comments

@hsm207
Copy link
Contributor

hsm207 commented Jan 11, 2018

In the GaussianVAE2D class definition in the file common_net.py, there is a method named sample.

This is how its defined:

  def sample(self, x):

    mu = self.en_mu(x)

    sd = self.softplus(self.en_sigma(x))

    noise = Variable(torch.randn(mu.size(0), mu.size(1), mu.size(2), mu.size(3))).cuda(x.data.get_device())

    return mu + sd.mul(noise), mu, sd

I don't understand why noise is defined as a Variable because we do not need to differentiate the loss function with respect to it, do we?

@hsm207 hsm207 changed the title Why is noise in GaussianVAE2D a torch Variable? Why is noise in GaussianVAE2D a torch Variable? Jan 11, 2018
@mingyuliutw
Copy link
Owner

This is an implementation of the reparamerterization trick described in the VAE paper. Basically, replacing the non differentiable sampling operation with an arithmetic operation by using auxiliary stochastic variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants