Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGAN: Fix nonsense code and stick to original paper #210

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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