# GAN: Learning a data distribution through a minimax game

> GANs train a noise-to-sample generator against a real/fake discriminator. The paper derives the optimal discriminator and a JS-divergence equilibrium, while practice uses a non-saturating generator loss.

- URL: https://dmxsf.com/en/blog/generative-adversarial-nets/
- [DMXSF](https://dmxsf.com/en/about/)
- Published: 2014-06-20
- Updated: 2026-11-13
- Paper notes
- Paper: [Generative Adversarial Networks](https://arxiv.org/abs/1406.2661) (Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, et al. · NeurIPS 2014, 2014)

A generative adversarial network learns a samplable implicit distribution without an explicit density. G maps noise to data space and D distinguishes data from generated samples.

## How it works

The value combines log D(x) on data and log(1-D(G(z))) on generated samples. For fixed G, D*=p_data/(p_data+p_g), leading to a JS-divergence interpretation and equilibrium at p_g=p_data, D=1/2.

## What the evidence shows

Experiments on MNIST, TFD and CIFAR-10 show samples and nearest-neighbor checks. Their scale is modest; the lasting contribution is the framework and theory rather than modern image fidelity.

## A reproducible check

This snippet checks a public formula or configuration; it does not reproduce full training.

```python
pd, pg = 0.7, 0.3
d = pd/(pd+pg)
js = 0.5*(pd*__import__('math').log2(2*pd/(pd+pg)) + pg*__import__('math').log2(2*pg/(pd+pg)))
print("optimal D(x) =", d)
print("JS divergence =", js)
```

```text
optimal D(x) = 0.7
JS divergence = 0.05935455038465365
```

The arithmetic is reproducible, but model quality still depends on the full experiments in the paper.

## Limitations and common misreadings

Training can oscillate or collapse modes, and a strong discriminator weakens the original generator gradient. The paper therefore uses a non-saturating alternative; attractive samples do not prove full coverage.

## The key takeaway

GANs turn density estimation into a two-player game: the equilibrium is elegant, while optimization remains difficult.

## Further reading

- [Generative Adversarial Networks](https://arxiv.org/abs/1406.2661)
- [DDPM](https://dmxsf.com/en/blog/ddpm-denoising-diffusion-probabilistic-models/)
- [VAE](https://dmxsf.com/en/blog/auto-encoding-variational-bayes/)

## FAQ

### What do the two networks do?

The generator maps noise to samples; the discriminator estimates whether samples are real.

### What is the ideal equilibrium?

Generated and data distributions match, and the discriminator outputs one half.

### Why are GANs difficult to train?

Adversarial optimization can oscillate or collapse modes, and early generator gradients can vanish.
