032e88438b1b2690e538c2cf399ebceb76adbea9,models/networks.py,GANLoss,__call__,#GANLoss#Any#Any#,132

Before Change



    def __call__(self, input, target_is_real):
        target_tensor = self.get_target_tensor(input, target_is_real)
        return self.loss(input, target_tensor)


// Defines the generator that consists of Resnet blocks between a few
// downsampling/upsampling operations.

After Change


        
        if self.gan_mode in ["lsgan", "vanilla"]:
            target_tensor = self.get_target_tensor(prediction, target_is_real)
            loss = self.loss(prediction, target_tensor)
        elif self.gan_mode == "wgangp":
            if target_is_real:
                loss = -prediction.mean()
            else:
                loss = prediction.mean()
        return loss


def cal_gradient_penalty(netD, real_data, fake_data, device, type="mixed", constant=1.0, lambda_gp=10.0):
    calculate the gradient penalty loss, used in WGAN-GP paper https://arxiv.org/abs/1704.00028
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: junyanz/pytorch-CycleGAN-and-pix2pix
Commit Name: 032e88438b1b2690e538c2cf399ebceb76adbea9
Time: 2019-01-01
Author: junyanzhu89@gmail.com
File Name: models/networks.py
Class Name: GANLoss
Method Name: __call__


Project Name: open-mmlab/mmdetection
Commit Name: 2df1e0a0759f1321eb0a821f5aaada9facb40c5e
Time: 2019-01-13
Author: chenkaidev@gmail.com
File Name: mmdet/models/anchor_heads/rpn_head.py
Class Name: RPNHead
Method Name: loss


Project Name: Zhaoyi-Yan/Shift-Net_pytorch
Commit Name: f2dde224575dc44a9a394350bebfe8cd9d526326
Time: 2019-04-19
Author: yanzhaoyi@outlook.com
File Name: models/modules/losses.py
Class Name: GANLoss
Method Name: __call__