Paper commentary
Generative Modeling by Estimating Gradients of the Data Distribution
Generative models can sample by estimating gradients of the data distribution
- Problem Likelihood models need special architectures and GANs can be unstable. Score estimates break down when data lie on low-dimensional manifolds or in sparse low-density regions.
- Method The authors perturb data with Gaussian noise at many levels and train one score network across them. Annealed Langevin dynamics then samples from large noise down to small noise.
- Results The unconditional model scored 8.87 inception on CIFAR-10, compared to 8.22 for SNGAN.
Why likelihood models and GANs leave room for another route
Two families drive most recent progress in generative modeling: likelihood-based models and GANs. Likelihood-based models either build a normalized density with special architectures, such as autoregressive or flow models, or train on surrogate losses. GANs avoid some of these limits, but adversarial training can be unstable and the GAN objective can't compare models.
The authors instead target the score, which is the gradient of the log data density with respect to the input.
That gradient points toward where the log density rises fastest, so a good estimate would let samples climb toward high-density regions. The trouble starts when data lie on a low-dimensional manifold, because the gradient is then undefined in the ambient space. Score matching also stops giving a consistent estimator in that setting.
Data are also scarce in low-density regions, so score estimates there are inaccurate. Langevin sampling usually starts in those regions, so the estimation error feeds straight into the samples. Mixing between two modes is slow for the same reason, since the chain must cross low-density gaps.
How score matching learns a score without a density model
Score matching trains a network s_θ(x) to match the gradient of the log data density, so the density never has to be modeled first. Up to a constant, its objective is the expectation below. The trace of the Jacobian is the expensive part, because it scales poorly to deep networks and high-dimensional data.
Denoising score matching avoids the trace by perturbing each data point with noise q_σ(x̃|x) and matching the score of the perturbed distribution. Its optimum equals ∇_x log q_σ(x), which is close to the true data score only when the noise is small. Sliced score matching instead projects the Jacobian onto random vectors v, which keeps the estimate tied to the unperturbed data.
That route needs about four times more computation, because of forward mode auto-differentiation.
The networks in this work are trained with denoising score matching, which the authors judge slightly faster and a natural fit for perturbed data. They add that sliced score matching can train these networks just as well.
Testing the manifold and low-density problems
The authors train a ResNet with sliced score matching on CIFAR-10 to probe the manifold problem. Without noise the sliced score matching loss falls and then fluctuates irregularly. Adding Gaussian noise N(0, 0.0001) makes the loss curve converge, and that noise is nearly invisible for pixel values in [0, 1].
A two-mode mixture of Gaussians centred at (−5,−5) and (5,5) exposes the low-density problem. Score estimates are reliable only near the two modes, where the data density is high. When the modes have disjoint supports, the score doesn't depend on the mixing weight π, so Langevin dynamics can't recover the relative weights from the score alone.
Langevin dynamics may still get the answer right in theory, but it can need a very small step size and very many steps to mix.
Noise at many levels with one score network
The key idea is to blur the data with Gaussian noise at several levels and learn one score model that works at every level. Noise fills the whole space, so the perturbed distribution doesn't collapse onto a manifold and its score is defined everywhere.
Large noise also fills the low-density gaps, which gives the estimator more training signal there. Small noise keeps the perturbed data almost identical to the originals, so the final stage still targets the data. A single conditional network covers all levels, so the authors don't need a separate model for each one.
The sampler mirrors that schedule: it starts at large noise and anneals the level down. The idea borrows from simulated annealing and annealed importance sampling, which use intermediate distributions to improve mixing.
From a learned score to samples
Once a score model is trained, Langevin dynamics produces samples by repeatedly moving along the score and adding fresh noise. \[ \tilde{x}_t = \tilde{x}_{t-1} + \tfrac{\epsilon}{2}\nabla_x \log p(\tilde{x}_{t-1}) + \sqrt{\epsilon}\, z_t,\qquad z_t\sim\mathcal{N}(0,I) \] Here ϵ is a fixed step size, and the chain starts from a sample drawn from a prior π(x).
With finite steps a Metropolis-Hastings correction would be needed, but the authors treat its error as negligible when ϵ is small and T is large. So the score network only has to approximate ∇_x log p_data(x), and the sampler does the rest.
Training one network across all noise levels
The noise levels form a positive geometric sequence σ_1 through σ_L, where σ_1 is large enough to ease the earlier problems and σ_L small enough to barely change the data. Each perturbed distribution is defined as follows. \[ q_\sigma(x)=\int p_{\text{data}}(t)\,\mathcal{N}(x\mid t,\sigma^2 I)\,dt \] One network s_θ(x,σ) is trained to approximate ∇_x log q_σ(x) for every σ in the sequence.
Their score network combines a U-Net with dilated convolutions, and it uses instance normalization. Conditioning on each σ_i comes from a modified version of conditional instance normalization.
For a fixed σ, the network output is pushed toward the score of the Gaussian noise kernel, which is −(x̃ − x)/σ². The levels are combined as follows, with weight λ(σ)=σ². \[ \mathcal{L}(\theta;\{\sigma_i\}_{i=1}^L)=\frac{1}{L}\sum_{i=1}^{L}\lambda(\sigma_i)\,\ell(\theta;\sigma_i) \] The choice λ(σ)=σ² rests on an observation that trained networks have ‖s_θ(x,σ)‖_2 ∝ 1/σ, which keeps each weighted term at a similar scale.
How the annealed sampler moves down the noise levels
Annealed Langevin dynamics starts from a fixed prior such as uniform noise and runs Langevin steps at σ_1 first. Its final samples become the initial samples for the next, smaller noise level, and the step size shrinks along the way. \[ \alpha_i=\epsilon\,\frac{\sigma_i^2}{\sigma_L^2} \] This keeps the ratio of signal to noise in each update roughly constant across levels.
So each stage starts from good samples, and the final stage at σ_L gives samples from a distribution close to p_data.
On the two-mode mixture, with L = 10, σ_1 = 10 and σ_10 = 0.1, annealed Langevin recovers the relative weights of the two modes. Plain Langevin dynamics doesn't recover them.
What the image experiments show
The authors use MNIST, CelebA and CIFAR-10, with pixels rescaled to [0, 1]. CelebA images are center-cropped to 140× 140 and resized to 32× 32. They use L = 10 standard deviations, a geometric sequence running from σ_1 = 1 down to σ_10 = 0.01. For image generation they set T = 100 and ϵ = 2× 10−5, and they start from uniform noise. The authors found the results robust to T, and ϵ between 5× 10−6 and 5× 10−5 worked fine.
On CIFAR-10 the unconditional model scored 8.87±.12 inception, compared to 8.22±.05 for SNGAN. That inception score is above the conditional EBM's 8.30 and the conditional SNGAN's 8.60, a comparison the authors use to stress how strong it is. So the inception result is the stronger evidence, while the FID result is a comparison the authors frame as comparable rather than superior.
To test whether the multi-level design matters, the authors compare a baseline with one noise level, σ = 0.01, and vanilla Langevin dynamics. That baseline fails to generate reasonable images. The authors argue that the small noise avoids the manifold problem but gives no information on scores in low-density regions.
MNIST and CelebA are judged by eye, since their scores aren't widely reported and preprocessing such as crop size changes the numbers. The authors describe these samples as higher or comparable in quality to those of likelihood-based models and GANs.
Inpainting as a test of learned structure
Inpainting asks the model to fill occluded regions of an image. The authors note that PixelCNN can only impute images in raster scan order, while their method handles occlusions of arbitrary shape. This takes only a simple change to the annealed Langevin procedure.
Completions on CelebA and CIFAR-10 are diverse, and the authors read this as evidence of generalizable, semantically meaningful representations. The evidence is visual, since no numeric inpainting score appears in the text.
How this differs from Markov chain and likelihood-based approaches
Generative stochastic networks train a Markov chain whose equilibrium matches the data, and they start the chain near a training point. The annealed sampler here starts from unstructured noise instead.
Nonequilibrium thermodynamics, infusion training and variational walkback all train by maximizing an evidence lower bound. The authors say these tend to produce blurry samples, whereas their score objective gives images comparable to GANs. Their training also doesn't need a Markov chain, which the authors argue makes it more efficient and scalable.
Training and sampling are decoupled, so any score estimator can pair with any score-based sampler.
Limits of the evidence
Experiments cover only MNIST, CelebA and CIFAR-10. The architecture for other domains is left as future work. The mixing analysis assumes the Metropolis-Hastings error is negligible when ϵ is small and T is large, and no test of that assumption appears in the text.
The λ(σ)=σ² choice rests on an empirical observation about trained networks, not on a proof. MNIST and CelebA have no reported inception or FID scores in the text.
Paper info
- Authors
- Yang Song, Stefano Ermon
- Venue
- arXiv · Preprint
- First published
- 2019-7-12
- Added
- 2026-11-6
- Updated
- 2020-10-10
- Version
- v3
- arXiv
- 1907.05600
- Category
- cs.LG · stat.ML
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
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
Yang Song, Stefano Ermon (2019). Generative Modeling by Estimating Gradients of the Data Distribution. arXiv:1907.05600v3. https://arxiv.org/abs/1907.05600v3
BibTeX
@misc{song2019generative,
title = {{Generative Modeling by Estimating Gradients of the Data Distribution}},
author = {Yang Song and Stefano Ermon},
year = {2019},
eprint = {1907.05600},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1907.05600v3}
}