Wasserstein GAN (WGAN)

WGAN banner Kaggle

Summary

A GAN trains two networks against each other: a generator that makes fake samples, and a discriminator that tries to tell fake from real. Training is often unstable, and the discriminator’s loss says little about how good the samples are.

Wasserstein GAN (WGAN) changes what the two networks fight over. The discriminator becomes a critic that gives each sample a score, with no sigmoid at the end. The gap between the average score of real and fake samples estimates the Earth Mover’s (Wasserstein) distance between the two distributions, up to a constant factor.

To make this work, the critic must be a smooth (Lipschitz) function. The paper enforces this crudely, by clipping every critic weight to a small range such as [−0.01, 0.01].

In the paper’s experiments on bedroom images, the critic’s estimate went down as the samples got better, WGAN trained with generator designs that failed as standard GANs, and the authors saw no mode collapse.

What Problem Does It Solve

Imagine two piles of sand: one shaped like the real data and one made by the generator. A standard GAN’s judge only says “real” or “fake”. If the piles do not overlap at all, the judge wins every time and gives the generator no useful hint about which way to move.

The Wasserstein distance instead asks: how much sand must be moved, and how far, to turn one pile into the other? This number shrinks smoothly as the generator’s pile moves closer, even when the piles do not overlap. So the generator always gets a direction to improve, and the number itself shows how close it is.

Core Idea

  • Earth Mover’s distance: the lowest cost of moving probability mass from one distribution to the other, where cost is amount times distance (Section 2, equation 1).
  • Why it helps: it is continuous and differentiable almost everywhere under mild assumptions, while the Jensen-Shannon (JS) and KL divergences are not; the paper’s Example 1 shows two parallel lines where only the Earth Mover’s distance gives a usable gradient (Section 2, Theorem 1, Figure 1).
  • Kantorovich-Rubinstein duality: the distance equals the largest gap E[f(real)] − E[f(fake)] over all 1-Lipschitz functions f (Section 3, equation 2).
  • The critic: a network f_w with clipped weights is K-Lipschitz for some K, so maximising the gap gives K times the distance; the generator is trained to reduce it (Section 3, equation 3, Theorem 3).

Key Method Details

  • Algorithm 1: train the critic n_critic = 5 times per generator step, clip its weights to [−c, c] after every update, and train the generator on −mean(critic(fake)). The default values are learning rate α = 0.00005, c = 0.01 and batch size m = 64, with RMSProp for both networks (Section 3, Algorithm 1).
  • Optimizer: training “becomes unstable at times” with a momentum-based optimizer such as Adam on the critic, so the paper uses RMSProp (Section 4.2).
  • Weight clipping: the paper calls it “a clearly terrible way to enforce a Lipschitz constraint”: a large c makes the critic slow to train, a small c can make gradients vanish (Section 3).
  • Meaningful loss: the critic’s estimate correlated well with sample quality (Section 4.2, Figure 3), while the standard GAN’s JS estimate stayed flat or went up (Figure 4). The paper does not yet claim it as a way to compare models, because the constant factor depends on the critic (Section 4.2).
  • Stability: with a DCGAN critic, WGAN trained a DCGAN generator, one without batch normalization and a 4-layer MLP; the last two did poorly as standard GANs, and the authors saw no mode collapse with WGAN (Section 4.3, Figures 5–7).

Simplifications in This Notebook

The notebook trains on a toy 2D data set, a ring of 8 Gaussian blobs, instead of images. The generator and critic are small MLPs with two hidden layers of 128 units.

The WGAN uses the paper’s Algorithm 1 settings: RMSProp, learning rate 0.00005, clipping 0.01, batch size 64 and 5 critic steps per generator step. Like the authors’ released code, it gives the critic 100 steps at the start and every 500 iterations. For comparison, it trains a standard GAN with Adam on the same data. Both train for 10,000 generator iterations.

Every 250 iterations it records the WGAN critic’s estimate, the standard GAN’s JS estimate, and how close the samples are to the 8 modes.

What the Notebook Result Shows

The WGAN critic’s estimate was tiny because of the clipping: 0.000428 at the start and 0.000137 at the end. It fell while the samples improved during the first ~4,000 iterations, then stayed roughly flat with jumps. Its rank correlation with the samples’ distance to the modes was +0.742, so it did go down as the samples improved, as the paper reports. The standard GAN’s JS estimate rose as its samples improved (correlation −0.543), so it did not track quality.

But the standard GAN made better samples in this run: on average 0.138 from the nearest mode, with 63.6% within 0.1, against 0.424 and 5.8% for the WGAN. Both formed a ring through all 8 modes, but the standard GAN’s ring was much tighter. So WGAN’s advantage in sample quality is not shown in this small experiment.

Influence

OpenAlex lists about 7,100 citations for the arXiv version (7,064 when checked on 29 November 2026). Its best-known follow-up, Improved Training of Wasserstein GANs (WGAN-GP, Gulrajani et al., 2017), replaced weight clipping with a gradient penalty, answering the paper’s own call to find a better way to enforce the Lipschitz constraint (Section 3). The authors released their PyTorch code.


Resources

File Description
README.md This overview — a 5-minute read covering the paper’s summary, core idea, key method details, influence, and a plain-English explanation of the problem it solves
solution.ipynb From-scratch PyTorch implementation of the WGAN algorithm on a toy 2D data set, with a standard GAN for comparison
CODE_ARCHITECTURE.md Section-by-section breakdown of the notebook — what each cell does, data flow, tensor shapes, and key design decisions
TALK.md Press coverage, Q&A (answers from the paper), citations, and common misconceptions about the paper

Table of contents