# Diffusion Models Beat GANs on Image Synthesis

Prafulla Dhariwal, Alex Nichol · arXiv · 2021-5-11

- **Problem** GANs hold the best sample quality on most image generation tasks, while diffusion models still trail them on harder datasets such as ImageNet.
- **Method** Improves the diffusion UNet through a series of ablations, then adds classifier guidance, which shifts each reverse sampling step by the scaled gradient of a noise-trained classifier.
- **Results** Reached FID 2.97 on ImageNet 128×128 with ADM-G and FID 4.59 on ImageNet 256×256, both with 250 sampling steps.

## Why GANs still lead image synthesis

GANs currently hold the best sample quality on most image generation tasks when judged by FID, Inception Score and Precision. They are also hard to train, since they collapse without carefully chosen hyperparameters and regularizers, and they capture less diversity than the best likelihood-based models. Diffusion models are likelihood-based, cover the data distribution well, have a stationary training objective and scale easily, and they have recently produced high-quality images.

On harder datasets such as LSUN and ImageNet, diffusion models still trail GANs. The best ImageNet 256×256 result from an upsampling diffusion stack still had an FID that was not competitive with BigGAN-deep.

The authors hypothesize two causes: GAN architectures have been refined heavily, and GANs can trade diversity for fidelity, producing high-quality samples without covering the whole distribution. The study therefore improves the architecture first, then adds a way to trade diversity for fidelity.

## How diffusion sampling and training work

Training draws a data sample, a timestep and noise, forms the noised sample x\_t, and fits the network ε\_θ(x\_t, t) with a mean-squared error between the predicted and true noise. Ho et al. found that this simple loss, L\_simple, works better in practice than the variational lower bound L\_vlb.

Each reverse step is modelled as a Gaussian p\_θ(x\_{t-1} \| x\_t) with a mean computed from ε\_θ and a variance Σ\_θ, and the variance can be fixed or learned. Nichol and Dhariwal learn the variance by interpolating in log space between β\_t and β̃\_t through a network output v, \\\\\[ \\\\Sigma\_\\\\theta(x\_t,t) = \\\\exp\\\\big(v \\\\log \\\\beta\_t + (1-v)\\\\log \\\\tilde\\\\beta\_t\\\\big) \\\\\] Training uses the hybrid objective L\_simple + λL\_vlb, which this work adopts throughout.

DDIM uses a non-Markovian noising process with the same forward marginals as DDPM but a different reverse noise. Setting that reverse noise to zero makes the sampler deterministic, and the authors use this DDIM sampler when they take fewer than 50 sampling steps.

## How sample quality is measured

FID is the default metric because it captures both diversity and fidelity and has been the common standard in state-of-the-art generative modeling. Inception Score rewards covering the ImageNet class distribution while producing convincing single-class samples, but it does not reward diversity within a class and can stay high for models that memorize a small subset.

sFID applies FID to spatial features instead of pooled features, which rewards coherent high-level structure. Improved Precision and Recall separate fidelity, the fraction of model samples inside the data manifold, from diversity, the fraction of data samples inside the sample manifold. Precision or IS is used to measure fidelity and Recall to measure diversity.

Published numbers are not always comparable, because some papers use arbitrary training subsets as reference and implementation details change FID values.

## Architecture changes that improve FID

The starting point is the UNet from Ho et al., with residual layers, downsampling and upsampling convolutions, skip connections, a global attention layer at 16×16 with a single head, and a timestep projection in each residual block. The authors vary depth against width, the number of attention heads, attention at 32, 16 and 8 resolutions, BigGAN residual blocks for resampling, and rescaling of residual connections by 1/√2.

Each comparison trains on ImageNet 128×128 with batch size 256 and samples with 250 sampling steps.

Apart from residual rescaling, the other modifications improve FID and have a positive compounding effect.

Plotting FID against wall-clock time favors 64 channels per head, which the authors adopt as their default, and this choice also matches common Transformer designs.

Replacing AdaGN with the addition plus GroupNorm layer from Ho et al. raised FID from 13.06 to 15.08.

The ablations in this section used 128 base channels and trained for 700K iterations.

## Steering sampling with classifier gradients

Earlier work showed that a pre-trained diffusion model can be conditioned with classifier gradients, and the authors build on that idea. They train a classifier p\_φ(y \| x\_t, t) on noisy images x\_t and use ∇\_{x\_t} log p\_φ(y \| x\_t) to guide sampling toward a target label y.

Conditioning the reverse transition on y multiplies the unconditional transition by the classifier probability and renormalizes, \\\\\[ p\_{\\\\theta,\\\\phi}(x\_t \\\\mid x\_{t+1}, y) = Z\\\\, p\_\\\\theta(x\_t \\\\mid x\_{t+1})\\\\, p\_\\\\phi(y \\\\mid x\_t) \\\\\] where Z is a normalizing constant. A Taylor expansion of the classifier log-probability around the mean μ, under a low-curvature assumption that holds in the limit of infinitely many steps, leaves a Gaussian whose mean is shifted by Σg, with g the classifier gradient at μ, \\\\\[ z \\\\sim \\\\mathcal{N}(\\\\mu + \\\\Sigma g, \\\\Sigma) \\\\\]

The sampler multiplies this gradient by a gradient scale s, which the authors include as an optional factor in the sampling algorithm. Because DDIM is deterministic, the stochastic derivation does not apply, so the authors use the score view of the noise predictor, ∇\_{x\_t} log p\_θ(x\_t) = -ε\_θ(x\_t)/√(1-ᾱ\_t), and combine it with the classifier gradient.

The resulting modified noise prediction is \\\\\[ \\\\hat\\\\epsilon(x\_t) := \\\\epsilon\_\\\\theta(x\_t) - \\\\sqrt{1-\\\\bar\\\\alpha\_t}\\\\,\\\\nabla\_{x\_t}\\\\log p\_\\\\phi(y \\\\mid x\_t) \\\\\] and it replaces ε\_θ in the regular DDIM update.

The classifier reuses the downsampling trunk of the UNet, with an attention pool at the 8×8 layer, and it is trained on the same noising distribution as its diffusion model. Random crops are added to reduce overfitting.

In early unconditional ImageNet experiments a gradient scale larger than 1 was needed: at scale 1 the classifier gave the desired classes about 50% probability, but the samples did not match them visually. Larger scales pushed the classifier probabilities close to 100%, because scaling by s makes the guided distribution proportional to p(y \| x)^s, which is sharper than p(y \| x) when s is above 1.

The authors note that a larger scale concentrates samples on the classifier modes, which favors fidelity at the cost of diversity.

## How the gradient scale trades recall for precision

On an unconditional diffusion model, guidance toward the class Pembroke Welsh corgi at scale 1.0 gave FID 33.0 and samples that were not convincing for the class. At scale 10.0 the same setup gave FID 12.0 and more class-consistent images.

On ImageNet 256×256, with models trained for 2M iterations at batch size 256, the conditional model without guidance reached FID 10.94 with precision 0.69 and recall 0.63. At scale 1.0 the same model reached FID 4.59, with precision rising to 0.82 and recall falling to 0.52. At scale 10.0 it reached FID 9.11, with precision 0.88 and recall 0.32.

Guidance therefore improves precision at the cost of recall, which the authors present as a trade-off between fidelity and diversity.

For the unconditional model, FID was 26.21 without guidance, 33.03 at scale 1.0 and 12.00 at scale 10.0. Guidance with a high enough scale brings the unconditional model close to the FID of the unguided conditional model, although training with class labels still helps.

Figure 4 varies the gradient scale from 0 to 10 for a class-conditional ImageNet 128×128 model. Scaling beyond 1.0 smoothly trades recall for higher precision and IS, and FID and sFID reach their best values at an intermediate scale.

## Comparison with GANs on LSUN and ImageNet

Without classifier guidance, ADM reaches the best FID in Table 5 on LSUN bedrooms, horses and cats and on ImageNet 64×64. The dropout variant of ADM reached FID 1.90 on bedrooms, 2.57 on horses and 5.57 on cats, against StyleGAN's 2.35, StyleGAN2's 3.84 and StyleGAN2's 7.25 on the respective classes. On ImageNet 64×64, ADM reached FID 2.61, against 4.06 for BigGAN-deep.

The LSUN models were sampled with 1000 steps.

On ImageNet 128×128, ADM-G reached FID 2.97 against 6.02 for BigGAN-deep, with recall 0.59 against 0.35. On ImageNet 512×512 it reached FID 7.72 against 8.43 for BigGAN-deep, with recall 0.42 against 0.29. BigGAN-deep keeps higher precision in all three ImageNet rows, at 0.86, 0.87 and 0.88 against 0.78, 0.82 and 0.87 for ADM-G.

The authors state that these guided models match GAN-level perceptual quality while keeping higher recall, and that they can do so with only 25 diffusion steps.

Figure 6 sets BigGAN-deep samples at truncation 1.0 with FID 6.95 beside guided diffusion samples with FID 4.59 and with training-set images. The authors argue that the diffusion samples show more modes, such as zoomed ostrich heads, single flamingos, different cheeseburger orientations and a tinca fish without a human holding it.

## Guidance combined with upsampling

Two-stage upsampling trains a low-resolution diffusion model and a second model that upsamples its output. The upsampler is conditioned on the low-resolution image, concatenated channel-wise to its input after simple interpolation, and sampling feeds the low-resolution sample into it.

The authors use the upsampling stack of Nichol and Dhariwal with their architecture changes, calling it ADM-U, with base resolutions of 64 for the 256×256 models and 128 for the 512×512 models. When guidance is combined with upsampling, only the lower-resolution model is guided.

At 256×256, ADM-U reached FID 7.49 with 250 base and 250 upsampling steps, against 10.94 for ADM. Adding guidance to the base model gave FID 4.59, and guidance plus ADM-U gave FID 3.94. At 512×512, ADM-U reached FID 9.96, and guidance plus ADM-U reached FID 3.85 with 250 steps for both models. Using 25 steps for the guided base model and 250 for the upsampler gave FID 4.11 at 512×512.

Upsampling raises precision while keeping recall high, whereas guidance provides a knob that trades recall against much higher precision. The best FIDs come from guidance at the lower resolution before upsampling, which the authors read as evidence that the two approaches complement each other.

## Guidance against BigGAN-deep truncation

The truncation trick for GANs samples the latent vector from a truncated normal distribution, and raising truncation lowers diversity while raising fidelity.

Figure 5 compares BigGAN-deep at truncation levels 0.1 to 1.0 with classifier guidance at varying gradient scales on ImageNet 128×128. Classifier guidance is strictly better than BigGAN-deep when FID is traded against Inception Score. For the precision and recall trade-off, guidance is only a better choice up to a certain precision threshold, beyond which it cannot reach higher precision.

## Limitations

Classifier guidance is currently limited to labeled datasets, and no effective strategy is given for trading diversity against fidelity on unlabeled data. The authors suggest that clustering samples into synthetic labels, or training discriminators to detect samples from the true distribution, could extend the method.

Diffusion models are still slower than GANs at sampling time because they need multiple denoising steps and therefore multiple forward passes. The single-step distillation of DDIM by Luhman and Luhman is not yet competitive with GANs, although it beats earlier single-step likelihood models.

FID, Inception Score and precision-recall are not perfect proxies for sample quality, and better metrics remain an open problem. Some values in Table 5 are taken from earlier papers because public models or samples were not available.

The classifier-guided conditional experiments cover ImageNet at 128×128, 256×256 and 512×512, and the LSUN experiments cover only the bedroom, horse and cat classes.

## Paper info

- **Authors**: Prafulla Dhariwal, Alex Nichol
- **Venue**: arXiv · Preprint
- **First published**: 2021-5-11
- **Added**: 2026-10-20
- **Updated**: 2021-6-1
- **Version**: v4
- **arXiv**: 2105.05233
- **Category**: cs.LG · cs.AI · cs.CV · stat.ML
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2105.05233v4) · [PDF ↗](https://arxiv.org/pdf/2105.05233v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Prafulla Dhariwal, Alex Nichol (2021). Diffusion Models Beat GANs on Image Synthesis. arXiv:2105.05233v4. https://arxiv.org/abs/2105.05233v4

**BibTeX**

```
@misc{dhariwal2021diffusion,
  title = {{Diffusion Models Beat GANs on Image Synthesis}},
  author = {Prafulla Dhariwal and Alex Nichol},
  year = {2021},
  eprint = {2105.05233},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.05233v4}
}
```

## Other paper commentary

- [A Style-Based Generator Architecture for Generative Adversarial Networks](https://refivu.com/en/papers/4dbbd963-fe20-4e79-9ec9-730023411ef1-a-style-based-generator-architecture-for-generative.md)
- [Wasserstein GAN](https://refivu.com/en/papers/6fbb2587-49dc-4b1a-9bb9-ee89b40b9221-wasserstein-gan.md)
- [Zero-Shot Text-to-Image Generation](https://refivu.com/en/papers/ec261d9b-e98a-4dcc-8961-c79073db25e2-zero-shot-text-to-image-generation.md)
- [Score-Based Generative Modeling through Stochastic Differential Equations](https://refivu.com/en/papers/11d114a6-a425-47ea-9133-db43e9c355d2-score-based-generative-modeling-through-stochastic.md)
- [Denoising Diffusion Probabilistic Models](https://refivu.com/en/papers/3a1faf88-ed3a-4c3a-bf1e-1afc6e7184fa-denoising-diffusion-probabilistic-models.md)
- [High-Resolution Image Synthesis with Latent Diffusion Models](https://refivu.com/en/papers/33bd1500-c829-47e5-9545-ad078523241e-high-resolution-image-synthesis-with-latent-diffusion-models.md)
- [Robust Speech Recognition via Large-Scale Weak Supervision](https://refivu.com/en/papers/52603b17-2b8d-42a8-916e-6c06910f2ca7-robust-speech-recognition-via-large-scale-weak-supervision.md)
- [Neural Discrete Representation Learning](https://refivu.com/en/papers/111a9c5f-9d7d-4bff-bbad-a962285094a3-neural-discrete-representation-learning.md)
- [Momentum Contrast for Unsupervised Visual Representation Learning](https://refivu.com/en/papers/4093c4bb-ce8b-4d26-bded-60ec02bc0fac-momentum-contrast-for-unsupervised-visual-representation.md)
- [NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis](https://refivu.com/en/papers/574db119-6e77-4d31-8936-4265ae5865bc-nerf-representing-scenes-as-neural-radiance-fields-for.md)
- [Conditional Image Generation with PixelCNN Decoders](https://refivu.com/en/papers/d620de7d-0e07-454b-b445-aa0fcab72e1d-conditional-image-generation-with-pixelcnn-decoders.md)
- [Evaluating Large Language Models Trained on Code](https://refivu.com/en/papers/10d79a8a-e539-4768-b215-b5af91ac2dbf-evaluating-large-language-models-trained-on-code.md)

## Terms in this paper

- [ImageNet](https://refivu.com/en/terms/5eadad128667-imagenet)
- [inception score](https://refivu.com/en/terms/25dbfbd4fd96-inception-score)
- [diffusion models](https://refivu.com/en/terms/39b044617fcd-diffusion-models)
- [DDIM](https://refivu.com/en/terms/6c24451d09a5-ddim)
- [DDPM](https://refivu.com/en/terms/f18692fc86b6-ddpm)
- [UNet](https://refivu.com/en/terms/0da000173b9b-unet)
- [GANs](https://refivu.com/en/terms/f248eedc996b-gans)
- [StyleGAN2](https://refivu.com/en/terms/77cd7d2c5d81-stylegan2)
- [truncation trick](https://refivu.com/en/terms/faba993d0c6e-truncation-trick)
- [BigGAN-deep](https://refivu.com/en/terms/3c37d61e65b8-biggan-deep)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/c4296a34-b538-4422-b11f-4a805621a24f-diffusion-models-beat-gans-on-image-synthesis)
