Multi-class Generative Adversarial Networks with the L2 Loss Function

Xudong Mao, Qing Li, Haoran Xie, Raymond Y. K. Lau, Zhen WangarXiv 2016 · OpenReview

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

Generative Adversarial Networks (GANs) have revolutionized unsupervised learning, enabling the synthesis of highly realistic data. However, training "Vanilla" GANs—which utilize a discriminator as a binary classifier with a sigmoid cross-entropy loss—is often unstable. A primary cause of this instability is the vanishing gradient problem. When generated "fake" samples are correctly classified by the discriminator but still reside far from the real data manifold, the sigmoid cross-entropy loss provides negligible gradients. Consequently, the generator receives little feedback to improve these samples, often leading to poor image quality or mode collapse.

Least Squares GANs (LSGANs)

To address these limitations, we propose Least Squares Generative Adversarial Networks (LSGANs). The core innovation is replacing the sigmoid cross-entropy loss with a least squares ($L_2$) loss function.

Objective Function

In an LSGAN, the discriminator $D$ and generator $G$ minimize the following objectives:

  1. Discriminator: Minimize the squared distance between its predictions and the target labels ($b$ for real data, $a$ for fake data).
  2. Generator: Minimize the squared distance between the discriminator's prediction of fake data and a target value $c$ (the value $G$ wants $D$ to believe).
The least squares loss function is a parabola with a single minimum, preventing gradient saturation.

Why LSGANs Improve Stability and Quality

The shift to a least squares loss provides two major advantages. First, unlike the sigmoid function which saturates at the extremes, the $L_2$ loss is a parabola. It penalizes samples based on their distance from the decision boundary, even if they are on the "correct" side. This ensures the generator receives a constant, informative gradient, pushing fake samples toward the real data distribution.

Comparison of decision boundaries: (a) combined view; (b) sigmoid boundary saturates for distant samples; (c) LSGAN boundary provides gradients (arrows) that pull samples toward the manifold.

Second, the authors provide a mathematical proof showing that minimizing the LSGAN objective is equivalent to minimizing the Pearson $\chi^2$ divergence between the real and generated distributions. This divergence measure is often more robust for training generative models than the Jensen-Shannon divergence used in vanilla GANs.

Experimental Results

We evaluated LSGANs across several benchmarks, including the LSUN scene dataset and the HWDB1.0 handwritten Chinese character dataset.

High-Cardinality Multi-class Learning

Training on the HWDB1.0 dataset, which contains 3,740 classes, presented a significant challenge. To manage this, the authors introduced a linear mapping layer to compress large one-hot label vectors into dense embeddings. LSGANs successfully synthesized recognizable characters across this massive class space, demonstrating superior stability in high-cardinality environments.

Robustness and Quality

In qualitative comparisons on LSUN-bedroom, LSGANs produced sharper and more detailed images than DCGAN and EBGAN. Furthermore, in synthetic 2D Mixture of Gaussians experiments, LSGANs successfully captured all modes of the distribution, whereas regular GANs frequently suffered from mode collapse. Notably, LSGANs remained stable even when architectural safeguards like Batch Normalization were removed, a scenario where regular GANs typically fail.

Conclusion

LSGANs offer a simple yet powerful modification to the GAN framework. By adopting a least squares loss, we mitigate the vanishing gradient problem, leading to more stable training and higher-quality image generation. Future work will explore scaling these benefits to even higher-resolution datasets and more complex data manifolds.

Reference: Mao, X., Li, Q., Xie, H., Lau, R. Y., Wang, Z., & Smolley, S. P. (2017). Least Squares Generative Adversarial Networks. arXiv:1611.04076v3 [cs.CV].

Summary updated

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.
BibTeX
@misc{mao2016multi,
  author = {Xudong Mao and Qing Li and Haoran Xie and Raymond Y. K. Lau and Zhen Wang},
  title = {{Multi-class Generative Adversarial Networks with the L2 Loss Function}},
  year = {2016},
  eprint = {1611.04076},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1611.04076},
}
Figure