Skip to content

Conversation

@HydrogenC
Copy link

@HydrogenC HydrogenC commented Sep 26, 2024

Fix nonsense code in the training code:

if opt.rel_avg_gan:
g_loss = adversarial_loss(fake_pred - real_pred.mean(0, keepdim=True), valid)
else:
g_loss = adversarial_loss(fake_pred - real_pred, valid)
# Loss measures generator's ability to fool the discriminator
g_loss = adversarial_loss(discriminator(gen_imgs), valid)

As shown above, g_loss is assigned and then immediately overwritten, which makes no sense.

Adjustments to better stick to the original paper:

  • Update discriminator before generator instead of the opposite
  • Revamp loss calculation code (see below)

According to the paper, for RGAN:
1727357458440

For RaGAN:
1727357305323

Implementation reference:
https://github.com/AlexiaJM/RelativisticGAN/blob/master/code/GAN_losses_iter.py#L636-L639

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant