pix2pixHD icon indicating copy to clipboard operation
pix2pixHD copied to clipboard

Is it a possible bug or do I understand it wrong?

Open simmed00 opened this issue 4 years ago • 4 comments

pred_fake_pool = self.discriminate(input_label, fake_image, use_pool=True) loss_D_fake = self.criterionGAN(pred_fake_pool, False)

pred_real = self.discriminate(input_label, real_image) loss_D_real = self.criterionGAN(pred_real, True)

pred_fake = self.netD.forward(torch.cat((input_label, fake_image), dim=1))
loss_G_GAN = self.criterionGAN(pred_fake, True)

In the last line, calculating loss_G_GAN, the input is the input label and the generated fake image, but in the criterionGAN(), the input is pred_fake and True. Shouldn't that be False?

I can see the the first line, pred_fake_pool, where the input is the input label and the generated fake image, the input for criterionGAN is pred_fake_pool and False. This is as expected. But what does the third loss do?

simmed00 avatar Oct 23 '20 05:10 simmed00

The third loss loss_G_GAN is the adversarial loss for the generator G. This loss models the generator's objective to make the discriminator "classify" fake images as real (thus the True instead of False), thus fooling him. This loss is used alongside the feature matching loss and VGG loss to update only the generator's weights.

Whereas the first two losses loss_D_fake and loss_D_real constitute the adversarial loss(es) for the discriminator D, whose objective it is to classify real images as real and fake images as fake.

In other words, the second argument to self.criterionGAN, i.e. the __call__ function of the class GANLoss, states not whether the input image was real, but whether or not the discriminator should, for this loss function to be minimal, classify the input image as real.

kplum avatar Jan 04 '21 16:01 kplum

Hello, I would like to know what's the best value should loss_G_GAN and loss_D should be? Thank you.

Wangyulin-user avatar Mar 23 '21 09:03 Wangyulin-user

@Wangyulin-user Unfortunately there is no best loss value for GAN training.

kplum avatar Mar 23 '21 09:03 kplum

But I got (epoch:12, iters:1, time:0.053) GAN: 6.444 GAN_Feat: 73.641 D_Fake: 0.001 D_real: 0.001, so I think the training model is failed, I am wondering what are the normal losses supposed to look like.

Wangyulin-user avatar Mar 23 '21 09:03 Wangyulin-user