import hyperchamber as hc
import torch

from hypergan.losses.base_loss import BaseLoss

class StandardLoss(BaseLoss):
    def _forward(self, d_real, d_fake):
        criterion = torch.nn.BCEWithLogitsLoss()
        g_loss = criterion(d_fake, torch.ones_like(d_fake))
        d_loss = criterion(d_real, torch.ones_like(d_real)) + criterion(d_fake, torch.zeros_like(d_fake))

        return [d_loss, g_loss]


@@ -79,16 +79,48 @@
 BaseLoss
+%0Aimport torch.nn.functional as F
 %0A%0Aclass 
@@ -432,8 +432,311 @@
 _loss%5D%0A%0A
+    def div(self, p, q):%0A        return F.sigmoid(p)*torch.log(F.sigmoid(p)/(F.sigmoid(q)+self.eps))%0A        #return F.sigmoid(p)*torch.log(self.two*F.sigmoid(p)/(F.sigmoid(p)+F.sigmoid(q)+self.eps))%0A    def forward_adversarial_norm(self, d_real, d_fake):%0A        return self.div(d_real, d_fake).mean()%0A

use kl div for norm