CycleGAN-keras
CycleGAN-keras copied to clipboard
Loss is incorrect?
Hi,
Thanks for your valuable code. But I don't quite follow the logic for calculating the gan loss in the cyclegan.py. My understanding is the discriminator tries to tell the real one is real(1), fake one is fake(0). so in cyclegan.py
for _ in range(opt.d_iter):
_, D_loss_real_A, D_loss_fake_A, D_loss_real_B, D_loss_fake_B = \
self.D_trainner.train_on_batch([real_A, fake_A, real_B, fake_B],
[zeros, ones*0.9, zeros, ones*0.9])
should be
for _ in range(opt.d_iter):
_, D_loss_real_A, D_loss_fake_A, D_loss_real_B, D_loss_fake_B = \
self.D_trainner.train_on_batch([real_A, fake_A, real_B, fake_B],
[ones*0.9, zeros, ones*0.9, zeros])
While the generator tries to fool the system to treat fake one as real. so in cyclegan.py
_, G_loss_fake_B, G_loss_fake_A, G_loss_rec_A, G_loss_rec_B = \
self.G_trainner.train_on_batch([real_A, real_B],
[zeros, zeros, real_A, real_B, ])
should be
_, G_loss_fake_B, G_loss_fake_A, G_loss_rec_A, G_loss_rec_B = \
self.G_trainner.train_on_batch([real_A, real_B],
[ones, ones, real_A, real_B, ])
Have you tried same experiment e.g. horse2zebra using this code? How many epochs can you obtain reasonable results? I tried to run the code with tensorflow backend with slightly modification but never obtain correct results. I am wondering if this logic mentioned above has something to do with it. Please advice. Thanks.