Generative adversarial network (GAN)

A generative adversarial network is a generative model made of two neural networks trained against each other: a generator that creates fake samples and a discriminator that tries to tell them apart from real data.

A GAN sets up a contest. The generator takes random noise and turns it into a sample, such as an image. The discriminator looks at a mix of real training examples and the generator's output and estimates which are real. The generator is trained to make the discriminator wrong, and the discriminator is trained to be right. As each improves, the other has to improve too.

Ian Goodfellow and colleagues at the Université de Montréal introduced the idea in June 2014. Their paper framed training as a two-player game and showed that, in theory, it has a single solution in which the generator reproduces the distribution of the training data exactly and the discriminator can do no better than guess, outputting one half everywhere. A curious feature is that the generator never sees a real image directly; it learns only from the discriminator's verdicts.

In practice the contest is hard to referee. A common failure is mode collapse, where the generator finds a few outputs that fool the discriminator and produces little else; one classic example is a GAN trained on handwritten digits that only ever draws one digit. Training can also fail to settle, or stall when the discriminator becomes so good that the generator gets no useful signal. Variants such as the Wasserstein GAN were designed to ease these problems.

For several years GANs produced the most convincing synthetic images. Nvidia researchers Tero Karras, Samuli Laine and Timo Aila published StyleGAN in December 2018; it separated broad attributes of a face, such as pose and identity, from fine detail such as freckles and hair, and came with a new high-quality dataset of human faces. GAN-made faces were soon being used for fake social media profiles and deepfakes, and in 2019 California passed laws, AB-602 and AB-730, aimed at some of these uses.

The lead in image generation then passed to diffusion models. In May 2021 Prafulla Dhariwal and Alex Nichol published Diffusion Models Beat GANs on Image Synthesis, reporting better image quality than the best GANs on standard tests. Text-to-image systems such as Stable Diffusion are built on diffusion rather than adversarial training, while GANs are still applied in areas such as scientific simulation and medical imaging research.

Common questions

How does a GAN work?

Two networks are trained together. The generator turns random noise into samples, and the discriminator judges whether each sample is real or generated. The generator improves by learning to fool the discriminator, and the discriminator improves by learning to catch it.

Who invented GANs?

Ian Goodfellow and colleagues at the Université de Montréal, including Yoshua Bengio, introduced them in a paper submitted in June 2014. Earlier work by Jürgen Schmidhuber on networks competing in a zero-sum game is sometimes cited as a precursor.

What is mode collapse?

Mode collapse is when a GAN's generator settles on a narrow range of outputs that reliably fool the discriminator instead of covering the full variety of the training data. A face generator might produce only a few similar faces, or a digit generator only one digit.

Are GANs still used, or have diffusion models replaced them?

Diffusion models have taken over most high-profile image generation since a 2021 paper showed them beating GANs on image quality, and systems such as Stable Diffusion use diffusion. GANs are still applied in areas such as scientific simulation and medical imaging research.

Finding more

Search for "generative adversarial network", "mode collapse" or "StyleGAN" to see how GANs work and where they succeeded. Reliable sources include the original papers on arXiv, encyclopedia articles that cite them and university course material on generative models. Be careful with older articles that describe GANs as the state of the art for images, since that changed after 2021.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.