Wasserstein GAN and Gradient Penalty
Swapping a GAN's discriminator for a 'critic' that estimates earth-mover distance instead of a fake-or-real probability fixes vanishing gradients and mode collapse — provided the critic is kept Lipschitz, which a gradient penalty enforces directly.
Prerequisites: The GAN Minimax Objective
Ordinary GAN training suffers a specific, well-diagnosed failure: once the discriminator gets very good at telling real from fake, its output saturates near or almost everywhere, and the gradient the generator receives — which flows through the discriminator — shrinks toward zero right when the generator needs guidance most. The generator ends up with almost no signal for how to improve. A Wasserstein GAN (WGAN) sidesteps this by changing what the second network measures, from a probability to a distance, which turns out not to saturate the same way.
The analogy: moving piles of sand
Think of the real data distribution and the generated distribution as two piles of sand of the same total weight but different shapes. The Wasserstein (earth-mover) distance is, informally, the minimum total amount of sand you'd have to shovel, multiplied by how far you'd have to carry each shovelful, to reshape one pile into the other. Unlike a probability of "is this grain real or fake," this distance changes smoothly as the piles get closer or farther apart — it never flattens out to an uninformative constant, so it keeps giving useful directional feedback even when the two piles are already fairly similar.
The critic, and the constraint it needs
WGAN replaces the discriminator with a "critic" that outputs an unbounded real number rather than a probability, and trains it to approximate the Wasserstein distance via:
In words: find the critic that scores real samples as high as possible and generated samples as low as possible, subject to being 1-Lipschitz — meaning 's output can't change faster than its input does, formally for any two points. That Lipschitz constraint is not optional decoration; without it the critic can make the gap between real and fake scores arbitrarily large by scaling itself up, which is meaningless and gives no useful gradient either.
Gradient penalty (WGAN-GP) enforces the constraint softly by penalizing the critic whenever its gradient norm strays from , checked at random points interpolated between real and fake samples:
In words: sample points between real and fake data, measure how steeply the critic's output changes there, and penalize any deviation from exactly slope — pushing the critic to stay Lipschitz everywhere it might actually be evaluated, not just at the training points.
Worked example 1: computing the penalty at one point
Suppose at an interpolated point the critic's gradient has norm and . Penalty contribution: — a large penalty, correctly discouraging the critic from being this steep there. If training brings the gradient norm to : penalty , nearly nothing, as it should be for a critic that's almost exactly 1-Lipschitz at that point.
Worked example 2: why the Wasserstein estimate itself is informative
Suppose over a batch, and . The critic's estimate of the Wasserstein distance is . Unlike an ordinary GAN's discriminator accuracy (which can sit at 100% while telling you nothing about how different the distributions are), this number is an actual distance estimate: as training proceeds and the generator improves, this gap should shrink toward smoothly, and — unlike ordinary GAN loss curves — it correlates reasonably well with visual sample quality, which is why WGAN loss curves are usable as a rough training diagnostic in a way vanilla GAN losses are not.
Picture the descent above as the critic's own training: because its objective never saturates the way a discriminator's sigmoid output does, its gradient keeps a useful, non-vanishing slope for far more of training.
WGAN replaces a probability-estimating discriminator with a distance-estimating critic constrained to be 1-Lipschitz, and gradient penalty enforces that constraint by penalizing gradient norms that stray from 1 at interpolated points — fixing the vanishing-gradient failure of vanilla GANs and giving a loss number that actually tracks sample quality.
What this means in practice
WGAN-GP is close to a default choice whenever GAN training is unstable or mode-collapsing, including in financial applications like QuantGAN-style synthetic return generation, where a vanishing generator gradient would mean the model stops improving on the specific stylized facts (fat tails, volatility clustering) that matter most. The Lipschitz constraint has a real cost, though: it can slightly limit how sharp the critic's decision boundary is allowed to be.
A frequent mistake is applying the gradient penalty only at real or only at fake samples, rather than at points interpolated between them. The Lipschitz constraint must hold everywhere the critic might be evaluated during generator training, and the region between the two distributions is exactly where that matters most — penalizing only the endpoints leaves the constraint unchecked in the region doing the real work.
Related concepts
Practice in interviews
Further reading
- Arjovsky, Chintala & Bottou, Wasserstein GAN (2017)
- Gulrajani et al., Improved Training of Wasserstein GANs (2017)