psanch21 / VAE-GMVAE

This repository contains the implementation of the VAE and Gaussian Mixture VAE using TensorFlow and several network architectures
Apache License 2.0
206 stars 32 forks source link

Why use z_x directly to generate x #3

Closed shaojinding closed 5 years ago

shaojinding commented 5 years ago

Hi psanch21,

Thanks for sharing the code and your thesis. I read the code and found that you used z_x directly to generate x in GMVAE_grpah.py, as self.x_recons_mean_flat = self.Px_z_graph(self.z_x, self.reuse) From my understanding, z should be generated from y and w in the generating process. Is there a reason for using z_x directly to generate x? Looking forward to your response, and please correct me if I was wrong.

psanch21 commented 5 years ago

Hi burningding, thank you for your question. You are partially right, let me explain. As you mentioned, in the generating process z is generated from p(z | y, w) this means we first need to sample from p(y) and p(w). However, I think the line of code you refer to correspond to the training phase. If you take a look at the expression of the ELBO you may see the expectation is over the posterior distribution q(z|x). This is the reason why 'self.z_x' is used. I hope this helps!

shaojinding commented 5 years ago

Hi psanch, appreciate your reply. Did you mean that the expectation of the Reconstruction Term in loss function is over q(z|x), so that's why you sampled x from self.z_x in training?

psanch21 commented 5 years ago

That's it!