What are GANs?
A GAN trains a generator to fool a discriminator that is trying to tell real data from fakes. The game is the lesson; in 2026, diffusion and flow models are what you ship for images.
Explain like I'm new to AI
An autoencoder rebuilds this x. A generative adversarial network (GAN) wants to mint new x that look like the training set. Two players:
- Generator G: takes noise
z ~ N(0,1)(or a class label, or a text embedding) and emits a fakex̂ = G(z). - Discriminator D: sees real
xand fakex̂, outputs "probability this is real."
D is trained like a classifier. G is trained to make D say "real" on fakes. Neither has a reconstruction target for a particular training image — the pressure is statistical. That is why GANs could look sharper than VAEs (no pixelwise average) and why they were infamously unstable.
2026 honesty: diffusion and flow-matching dominate image (and video) generation products. StyleGAN-era faces were a cultural moment; they are not what Midjourney / Flux / movie tools run. You still learn GANs because adversarial training shows up in distillation, discriminators-as-losses, and "don't let the model score its own homework." For the product picture of pixels-from-prompts, read Image & Video Generation.
Two networks, opposite jobs. Click who you are:
Alternate: a few D steps, a few G steps. Minimax, not a single loss that always goes down.
Oscillation is normal. In 2026, image gen is mostly diffusion / flow — GANs still teach the adversarial idea.
Honest timeline
Diffusion and flow-matching dominate products. GANs remain in some compression, graphics, and as a teaching tool.
Mental model
A forger (G) and a detective (D). The detective studies real paintings and the forger's latest work. The forger only gets a signal through the detective's judgment — not a pixel-by-pixel overlay of a specific Vermeer. If the detective is too good too fast, the forger gets "fake" on everything and no usable gradient. If the detective is lazy, the forger wins with a brown smudge. If the forger finds one face that always fools, they print that face forever (mode collapse).
How it works
The original minimax (Goodfellow 2014):
min_G max_D E_x[log D(x)] + E_z[log(1 − D(G(z)))]In practice G is often trained to maximize log D(G(z)) (non-saturating loss) because log(1 − D) is flat when D is confident the fake is fake.
Loop (the actual algorithm):
- Draw a minibatch of real
xand noisez. - Update D: real → 1,
G(z)→ 0. Freeze G. - Draw new
z. Update G to increase D(G(z)). Freeze D. - Repeat. Optionally k D steps per G step.
Tiny 1-d cartoon. Real data is x = 3 always. G is x̂ = z + g with z ~ N(0,1). D is σ(w · x + b). After D learns "near 3 is real," G's gradient on g should push g toward 3. If D saturates (D(x̂) ≈ 0 for all current fakes), ∂loss_G / ∂x̂ vanishes — G stops learning even though it is wrong. That is the instability in one dimension.
Architectures that made this usable: DCGAN (conv G/D, 2015), WGAN-GP (Earth-Mover distance + gradient penalty — smoother D), StyleGAN (style codes, faces). Conditioning: concat a class, or FiLM, or text embeddings (early text-to-image GANs; diffusion ate that product).
Real-world example
2018: a StyleGAN demo interpolates celebrity faces; every ML course adds a GAN notebook. 2026: the same course should say "this is adversarial training" and then open a diffusion notebook for the image product. Remaining GAN-shaped systems: some super-resolution discriminators, neural compression, game-texture tools, research on adversarial robustness. A company generating catalog photos from SKU text is almost certainly on a diffusion / flow API or checkpoint — see the multimodal lesson.
Technical explanation
At Nash equilibrium, for a powerful enough D, G's distribution matches the data distribution (in the original derivation). You never reach that. You get oscillation, mode collapse (low entropy G), discriminator collapse, sensitive learning rates, and a loss curve that does not mean what MSE means — D loss going down is not "the image got better." Evaluate with FID/IS/human raters, not "G loss."
Adversarial loss as a component: train a reconstructor with MSE + λ log D(x̂) so D criticizes blur. That hybrid is why "GAN" still appears in papers that are not standalone generators.
vs diffusion, one stanza. Diffusion trains a denoiser with a well-behaved regression (or score) loss; sampling is iterative. No second network that must stay perfectly matched. Slower sample, stabler train, better coverage of modes — the 2022–2026 empirical winner for pixels. Flow matching is the close cousin. GANs still sample in one forward pass, which is why they linger in real-time graphics.
| GAN | Diffusion / flow (2026 default) | |
|---|---|---|
| Train signal | Fool a discriminator (minimax) | Denoise / match a flow — a regression-like loss |
| Stability | Fragile; mode collapse; two timescales | Much calmer; loss actually trends |
| Sample speed | One (or few) forwards | Many steps (unless distilled) |
| Product image/video | Legacy / niches | What you actually ship |
Common mistakes
Starting a 2026 image product by training a GAN from scratch because the 2018 tutorial was memorable. Learn the game, then use diffusion/flow (or a vendor generator). Adversarial losses can still be a topping, not the whole meal.
- Watching G/D losses like training accuracy. They are a match score, not image quality.
- Updating G and D with the same learning rate and the same number of steps "for fairness" — the heuristic is usually keep D a little ahead, not a god.
- Evaluating only on cherry-picked fakes; mode collapse looks great in a 4×4 grid of the same face.
When to use it
- To understand adversarial training, papers 2014–2021, and one-shot sampling constraints.
- As an auxiliary discriminator loss, or in domains where a fast G already works.
When NOT to use it
- Greenfield text-to-image / video — Image & Video Generation (diffusion, autoregressive visual tokens, flows).
- Any setting where you cannot afford a week of "maybe it will collapse on Tuesday."
Alternatives
- VAEs / VQ-VAEs — likelihood + latents; often the tokenizer in front of diffusion.
- Diffusion and flow-matching — default generators.
- Autoregressive image transformers — next-token on patches; another 2024–2026 line.
Quick quiz
Related concepts
- Image & Video Generation — Generators invent pixels from a prompt — they are not cameras. Photorealism is not proof.
- What are Autoencoders? — An autoencoder squeezes input through a bottleneck and reconstructs it. The code is an embedding; denoising and VAEs are the useful cousins.
Further reading
Last reviewed: 2026-09-04 · Written by ByHeart AI · Reviewed by ByHeart AI