eriklindernoren / Keras-GAN

Keras implementations of Generative Adversarial Networks.
MIT License
9.18k stars 3.14k forks source link

What are a,b,c in LSGAN? #156

Open mrgloom opened 5 years ago

mrgloom commented 5 years ago

In paper https://arxiv.org/pdf/1611.04076.pdf section 3.2.3 Parameters Selection in eq. 9 they use b=1, a=0, c=1, but I can't see this constants in the code: https://github.com/eriklindernoren/Keras-GAN/blob/master/lsgan/lsgan.py#L29 https://github.com/eriklindernoren/Keras-GAN/blob/master/lsgan/lsgan.py#L50

amtamasi commented 5 years ago

The paper says that a and b are the respective labels for fake data and real data that the discriminator assigns during training to calculate the loss. On lines 103 and 104, "valid" and "fake" are arrays initialized to all zeros and all ones respectively to be used in training. Fake corresponds to the parameter a, and valid corresponds to b. This means that in the code, a=0 and b=1, reflecting what equation 9 says. Then on line 132, the generator's loss is calculated by training against the valid array (corresponding to b), which means that c=b=1 like in equation 9. So the constants are held as the valid and fake NumPy arrays!