All models

erik_lsgan

The generator from PyTorch-GAN's least squares GAN, a GAN trained with a least squares discriminator loss.

Diffusion and generative · 12 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (17 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
LSGAN
Parameters
1M
Operations
12
Framework
PyTorch
Recurrent
No
Published
ICCV 2017
Cited by
5,349 (as of 16 October 2026)
Authors
Xudong Mao, Qing Li, Haoran Xie and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m4680
Graph hash
ade907684099f2babf7fe498113c350e29e360b87e20f5e850a10567760e02be
Skeleton hash
4d8600ed2a4f373dd4905e941fad2306ab9cd2600e3d833d8b2fc561c3f8f649
Architecture hash
c3ea5199febe01c80671b06271b7c5b6c526c7b89fb747dbc6dad93ef02dc18a
Diagram SHA-256
6eb5ae379753ad7906f1d1bad6145de675f583c90d934d2bd5b796c632f174a0
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

About this model's family

Least Squares GANs, LSGAN for short, change one thing about a generative adversarial network: the discriminator is trained with a least squares loss instead of the sigmoid cross entropy of a regular GAN. The reason is vanishing gradients: fake samples that already sit on the real side of the decision boundary but are still far from the real data give the generator almost no error under cross entropy. A least squares loss instead penalizes samples that lie a long way on the correct side and pulls them toward the boundary even though they are correctly classified.

The paper shows that, with the label coding chosen so that b minus c is 1 and b minus a is 2, minimizing the LSGAN objective minimizes the Pearson chi-squared divergence. A second argument is that the least squares loss is flat at only one point, whereas sigmoid cross entropy saturates once its input is large. The two claimed benefits are higher quality images and more stable learning, evaluated on five LSUN scene datasets and a handwritten Chinese character dataset with 3740 classes. In the stability comparison the authors report that regular GANs suffered a severe degree of mode collapse where LSGANs did not.

The authors' own architecture follows DCGAN, with ReLU activations in the generator and LeakyReLU in the discriminator. The captured members are the generator from the PyTorch-GAN collection's lsgan.py rather than the authors' TensorFlow code, and both roster rows name that same module. That collection warns that its architectures will not always mirror the ones proposed in the papers, so the traced graph is a compact stand-in for the paper's generator. The official repository also points to a related project, improved_LSGAN, and a follow-up paper on the effectiveness of least squares GANs.

Key idea. Replacing the GAN discriminator's cross entropy with a least squares loss, which minimizes a Pearson chi-squared divergence and relieves vanishing gradients.

  • lsgan
  • least squares gan
  • least squares generative adversarial networks
  • gan loss
  • pearson chi-squared divergence
  • vanishing gradients
  • pytorch-gan
  • xudong mao
  • dcgan generator

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{mao2017squaresgenerativeadversarialnetworks,
      title={Least Squares Generative Adversarial Networks}, 
      author={Xudong Mao and Qing Li and Haoran Xie and Raymond Y. K. Lau and Zhen Wang and Stephen Paul Smolley},
      year={2017},
      eprint={1611.04076},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/1611.04076}, 
}