Last active
August 24, 2019 12:58
-
-
Save lasseha/e9e9dad51f440330005d32d8114d84f2 to your computer and use it in GitHub Desktop.
kld loss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def kld_loss(mu, logvar): | |
return (-0.5 * torch.mean(1 + logvar - mu.pow(2) - logvar.exp())) | |
def total_loss(img, recon, mu, logvar): | |
return l1_loss(recon, img) + kld_loss(mu, logvar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment