- Introduced by
- Goodfellow, I. et al.
- Year
- 2014
- Type
- Generative deep learning (adversarial two-network game)
What does it do?
A Generative Adversarial Network (GAN), introduced by Ian Goodfellow and colleagues in 2014, learns to generate synthetic data by pitting two neural networks against each other: a generator that produces samples and a discriminator that judges whether a sample is real or generated.
It is most often applied to image and audio synthesis and to generating synthetic training data.
The intuition behind the method
Think of a counterfeiter and a detective locked in a contest. The generator (counterfeiter) tries to produce fake samples convincing enough to pass as real, while the discriminator (detective) tries to tell real data from fakes. As each gets better at its job, the generator is forced to produce increasingly realistic output until its fakes become hard to distinguish from genuine data.
History
The Generative Adversarial Network was introduced by Ian Goodfellow and colleagues in 2014, framing generative modelling as a two-player game between a generator and a discriminator. It was developed independently of the variational autoencoder, at around the same time. The idea inspired many later variants for image synthesis and translation. Karras and colleagues (2020) analysed and improved the image quality of StyleGAN, a style-based GAN architecture, and reported state-of-the-art unconditional image-modelling results for that architecture. Diffusion models have since emerged as a leading alternative for high-quality generation.
When to use it
Choose a GAN when the goal is to generate realistic synthetic samples from high-dimensional continuous data, such as images or audio, for example for image synthesis or data augmentation, and a reasonably large training set is available. No validated minimum sample size is established for this method, so the adequacy of a dataset should be judged empirically. Do not choose a GAN when the dataset is small, because the generator and discriminator are then hard to balance; a variational autoencoder or a simpler augmentation method is more reliable in that case. Avoid a GAN if the task requires an explicit likelihood or density for new observations, since a GAN defines its generator only through samples. Training needs GPU resources, and the generator-discriminator balance must be watched for mode collapse throughout. Results also depend on architecture, normalization and regularization choices, so published architectures should be adopted and tuned rather than assumed to transfer to new data.
Limitations and considerations
- Training is unstable because two networks are optimised against each other, and it is prone to mode collapse, where the generator covers only part of the data distribution.
- Requires substantial computation, typically GPU hardware, when the data are high-dimensional.
- Needs a substantial training set; no validated minimum sample size is established here, and with small samples the adversarial balance is difficult to establish.
- Does not return an explicit density estimate, so it cannot by itself assign likelihoods to new observations.
- Unlike a variational autoencoder, it learns only a generator (decoder) and no encoder, so it is not designed to reconstruct specific input samples.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Learns to generate samples without requiring an explicit likelihood for the data, so the generator is trained through the discriminator's judgement of its outputs.
- Can produce high-fidelity images; the StyleGAN paper reports state-of-the-art unconditional image-modelling results for its own style-based architecture, not for GANs in general.
- Operates on high-dimensional continuous inputs such as images without assuming that the data are normally distributed.
Applications
- Image synthesis and the generation of realistic visual content.
- Data augmentation, subject to checks on the realism and diversity of the synthetic output.
- Synthetic data generation for high-dimensional continuous data.
- Audio and signal synthesis.
How it works
How it works
The generator takes random noise as input and maps it to a synthetic sample, with the aim of matching the distribution of the real data. The discriminator receives both real samples and generated ones and outputs the probability that each input is real. Because the inputs are typically high-dimensional, such as images or audio, training is computationally demanding and is usually run on GPU hardware.
The two networks are trained against each other on the value function given in the mechanics. The discriminator is updated to improve its ability to separate real samples from generated ones, while the generator is updated to reduce the discriminator's success on its outputs. Because one term of the objective depends on both networks, a change in one network alters the training signal for the other. In early training, when the discriminator rejects generated samples easily, the generator's gradient from this objective can be very small. A common heuristic is then to train the generator to maximise log D(G(z)) instead of minimising log(1 - D(G(z))). This heuristic works well in practice, but it no longer corresponds to the minimax formulation given in the mechanics.
Formula
\min_G \max_D \; \mathbb{E}_{x}[\log D(x)] + \mathbb{E}_{z}[\log(1 - D(G(z)))]Training proceeds by alternating these updates, and the objective does not by itself guarantee that the process settles at a stable point. In practice the balance between the two networks is monitored, because instability can cause mode collapse, where the generator produces only a narrow range of the possible outputs. Updating the generator for many steps without corresponding updates to the discriminator can cause it to repeatedly produce very similar samples, which is one way diversity is lost. Sample diversity is usually checked alongside visual or perceptual quality.
Common pitfalls
- Training on too little data, so the adversarial balance fails and mode collapse follows.
- Not monitoring for mode collapse and assuming varied output without checking sample diversity.
- Attempting to train without GPU resources for high-dimensional image or audio data.
- Reaching for a GAN on a small dataset where a variational autoencoder or simple augmentation would be more reliable.
Frequently asked questions
What is mode collapse?
Mode collapse occurs when the generator learns to produce only a narrow set of outputs that reliably fool the discriminator, instead of covering the full variety of the real data. It is a central failure mode of GAN training, especially on small datasets, and sample diversity should be monitored throughout training.
How much data do I need?
No validated minimum sample size is established for GAN training, so the adequacy of a dataset should be judged empirically. GANs generally need a substantial training set. With small datasets the generator and discriminator are harder to balance and the risk of mode collapse rises, so a variational autoencoder or a simpler augmentation method is usually the safer choice.
Do I need a GPU?
Usually yes. GANs are typically applied to high-dimensional data such as images and audio, and training two competing networks is computationally intensive, so GPU hardware is the normal choice.
How is a GAN different from a diffusion model?
A GAN generates through the adversarial competition of two networks. Sampling is a single forward pass through the generator, but training is unstable and prone to mode collapse. Diffusion models instead learn to reverse a step-by-step noising process and have become a strong alternative for high-quality generation.
Related methods
Sources
Goodfellow, I. et al. (2014). Generative Adversarial Nets. NeurIPS.
Open publication referenceKarras, T. et al. (2020). Analyzing and Improving the Image Quality of StyleGAN. CVPR.
Open DOI reference2018_Book_NeuralNetworksAndDeepLearning, p. 442