DGAI
DGAI copied to clipboard
Chapter 5: Understanding the cGAN's loss functions
Hi @markhliu,
I am not sure I understand the implementation of the critic's loss function in chapter 05:
loss_critic=(-(torch.mean(critic_real) - torch.mean(critic_fake)) + 10 * gp)
In the book on page 107, the formula is: critic_value(fake) - critic_value(real) + weight * GradientPenalty.
The values of critic_value(fake) and critic_value(real) are inverted by -1 and the overall result in parenthesis has a negative sign. This is also the case for the generator's loss: loss_gen = -torch.mean(gen_fake).
I understand that unlike in chapter 04, the discriminator / critic does not produce a value between 0 and 1 from which we can calculate the loss (namely 1 - prediction for real images from the training dataset and simply prediction for those made by the generator).
Instead, the critic produces a higher value for images classified as "more real" and a lower (negative) value classified as "more fake".
Thanks a lot for your feedback.