Least Squares Generative Adversarial Networks

Xudong Mao, Qing Li, Haoran Xie, Raymond Y.k. Lau, Zhen Wang, Stephen Paul Smolley · DOI

Abstract

Unsupervised learning with generative adversarial networks (GANs) has proven hugely successful. Regular GANs hypothesize the discriminator as a classifier with the sigmoid cross entropy loss function. However, we found that this loss function may lead to the vanishing gradients problem during the learning process. To overcome such a problem, we propose in this paper the Least Squares Generative Adversarial Networks (LSGANs) which adopt the least squares loss function for the discriminator. We show that minimizing the objective function of LSGAN yields minimizing the Pearson $\chi^2$ divergence. There are two benefits of LSGANs over regular GANs. First, LSGANs are able to generate higher quality images than regular GANs. Second, LSGANs perform more stable during the learning process. We evaluate LSGANs on five scene datasets and the experimental results show that the images generated by LSGANs are of better quality than the ones generated by regular GANs. We also conduct two comparison experiments between LSGANs and regular GANs to illustrate the stability of LSGANs.

Introduction

Standard Generative Adversarial Networks (GANs) often struggle with vanishing gradients and unstable training because their loss function "saturates." In a regular GAN, the discriminator acts as a classifier using a sigmoid cross-entropy loss. While effective, this approach has a major flaw: once a generated sample is on the "correct" side of the discriminator's decision boundary, the loss becomes very small.

This leads to two primary issues:

  1. Vanishing Gradients: If a generated sample is far from the real data but already on the correct side of the decision boundary, the generator receives almost no gradient to improve further.
  2. Poor Quality: Because the generator isn't penalized for being far from the real data (as long as it fools the discriminator), the resulting images can be unrealistic or lack diversity.

To address these, we introduce Least Squares GANs (LSGANs), which swap out the traditional sigmoid cross-entropy loss for a least squares objective.

Methods: The Least Squares Objective

The core innovation is the Least Squares loss function. Instead of asking the discriminator to output a probability (0 to 1), LSGAN asks it to solve a regression problem. This ensures that the generator receives a strong, non-vanishing gradient regardless of how far the sample is from the target.

Comparison of sigmoid cross entropy loss (a) and least squares loss (b).

The authors propose an $a-b-c$ coding scheme where $a$ is the target for fake data, $b$ is the target for real data, and $c$ is the value the generator wants the discriminator to believe for fake data. By setting these parameters (e.g., $a=0, b=1, c=1$), the discriminator is forced to penalize samples based on their distance from the decision boundary. Mathematically, minimizing the LSGAN objective is equivalent to minimizing the Pearson $\chi^2$ divergence between the real and generated data distributions.

Key Insights: The "Pulling" Effect

In a standard GAN, once a fake sample is "real enough" to fool the discriminator, the generator stops trying to improve it. In LSGAN, the least squares loss penalizes samples that are far from the boundary even if they are on the "correct" side. This "pulls" the generated samples toward the real data manifold.

Illustration of the decision boundaries and the 'pulling' effect.

As shown in the figure above, (b) demonstrates how the sigmoid decision boundary fails to provide a gradient for distant fake samples. In contrast, (c) shows the least squares decision boundary exerting a force (arrows) that pulls these samples toward the real data distribution.

Experimental Results

The authors evaluated LSGAN on several large-scale datasets, including LSUN (scene categories) and HWDB1.0 (handwritten Chinese characters).

  • Qualitative Superiority: LSGANs generated sharper and more realistic images compared to DCGAN and EBGAN.
  • Stability: LSGANs remained stable across multiple trials and different optimizer settings (Adam vs. RMSProp), even when Batch Normalization was removed—a scenario where regular GANs typically suffer from severe mode collapse.
  • Multi-class Success: The conditional LSGAN successfully learned to generate readable characters for all 3,740 classes in the HWDB1.0 dataset, demonstrating its ability to handle extremely high-cardinality label sets.

Conclusion

LSGANs offer a simple yet powerful modification to the standard GAN framework. By replacing the sigmoid cross-entropy loss with a least squares objective, the model achieves better gradient flow and forces generated samples to lie closer to the real data manifold. While future work could explore more direct ways to pull samples toward real data points or scaling to even larger datasets like ImageNet, LSGANs already represent a significant step forward in training stability and image quality.

Summary updated

BibTeX
@inproceedings{mao2017least,
  author = {Xudong Mao and Qing Li and Haoran Xie and Raymond Y.K. Lau and Zhen Wang and Stephen Paul Smolley},
  title = {{Least Squares Generative Adversarial Networks}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2017},
  doi = {10.1109/iccv.2017.304},
}
Figure