CycleGAN-keras icon indicating copy to clipboard operation
CycleGAN-keras copied to clipboard

identity loss is not correct

Open Trueyellow opened this issue 6 years ago • 1 comments

I found in cyclegan.py, you are using opt.idloss as the loss weight of identity loss

if opt.idloss > 0:
            G_trainner = Model([real_A, real_B], 
                     [dis_fake_B,   dis_fake_A,     rec_A,      rec_B,      fake_B,     fake_A])
            
            G_trainner.compile(Adam(lr=opt.lr, beta_1=opt.beta1,),
                loss=['MSE',        'MSE',          'MAE',      'MAE',      'MAE',      'MAE'],
                loss_weights=[1,    1,              opt.lmbd,   opt.lmbd,   opt.idloss  ,opt.idloss])

but, in the original pytorch version, they are using

if lambda_idt > 0:
            # G_A should be identity if real_B is fed.
            idt_A = self.netG_A(self.real_B)
            loss_idt_A = self.criterionIdt(idt_A, self.real_B) * lambda_B * lambda_idt  # loss part?

So I think the weight of identity loss should be opt.idloss*opt.lmbd?

Trueyellow avatar Nov 13 '17 16:11 Trueyellow

I implemented the code based on the paper. The only hyper-parameter in the Equ.3 is lambda. Feel free to change the code to include more tricks from the official repository.

Shaofanl avatar Nov 16 '17 18:11 Shaofanl