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

2nd element of recon_loss? #3

Open
YongWookHa opened this issue Nov 7, 2018 · 3 comments
Open

2nd element of recon_loss? #3

YongWookHa opened this issue Nov 7, 2018 · 3 comments

Comments

@YongWookHa
Copy link

Hello, I'm a student studying deep learning.
First of all, Your code is really helpful to learn about VAE.
Thank you very much.

I've got a question.
I'm curious about the reason that you put log(2pi) to the 2nd element recon_loss.

Thank you for the answer in advance.
Have a good day.

@moha23
Copy link

moha23 commented Dec 2, 2019

Hi, @YongWookHa were you able to figure the logic behind the reconstruction loss in vae_keras_celeba.py?

recon_loss = 0.5 * K.sum(K.mean(x_out**2, 0)) + 0.5 * np.log(2*np.pi) * np.prod(K.int_shape(x_out)[1:])

@YongWookHa
Copy link
Author

YongWookHa commented Dec 2, 2019

Hello, @moha23.
An year passed! :)

x_out = Subtract()([x_in, x_recon])
recon_loss = 0.5 * K.sum(K.mean(x_out**2, 0)) + 0.5 * np.log(2*np.pi) * np.prod(K.int_shape(x_out)[1:])

As I think, in recon_loss, 0.5 * K.sum(K.mean(x_out**2, 0)) refers MSE.
And added value of 0.5 * np.log(2*np.pi) * np.prod(K.int_shape(x_out)[1:]) is a constant value.
The code np.prod(K.int_shape(x_out)[1:]) calculates H x W x C.
I think this constant value works like a bias but not that meaningful.

So, I guess you would be able to get similar result without the latter code.
I'm sorry that i am not in a situation to simulate my theory.
I will put it off to you.

Have a nice day.

@moha23
Copy link

moha23 commented Dec 2, 2019

Thanks @YongWookHa! Yes that's the direction I was going too 👍

Wishing another fruitful year ahead :)

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