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

Possible mistake in vanilla_vae 'loss_function' #68

Open
sh3rlock14 opened this issue Sep 27, 2022 · 3 comments
Open

Possible mistake in vanilla_vae 'loss_function' #68

sh3rlock14 opened this issue Sep 27, 2022 · 3 comments

Comments

@sh3rlock14
Copy link

I think that in vanilla_vae.py loss_function there's a mistake in KLD returned value:

return {'loss': loss, 'Reconstruction_Loss':recons_loss.detach(), 'KLD':-kld_loss.detach()}

the negative sign (-) should not be there!

@dvalenciar
Copy link

Agree, the negative sign was already added before, so it should not be there

@chengengliu
Copy link

Agree. Line#143 already has one negative sign.

@Maximusprime3
Copy link

Maximusprime3 commented May 21, 2023

this also happens in the mssim_vae.py
line#155
`

    kld_loss = torch.mean(-0.5 * torch.sum(1 + log_var - mu ** 2 - log_var.exp(), dim = 1), dim = 0) 

    loss = recons_loss + kld_weight * kld_loss
    return {'loss': loss, 'Reconstruction_Loss':recons_loss, 'KLD':-kld_loss}`

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

4 participants