Before you use the demo in the newer notebook, say what you expect to change.
Foundation reference
Score Matching & Score-Based Generative Models
Score functions underlie diffusion models: the network trained at each noise level is, up to scaling, an estimate of the score of the noised data distribution (Song & Ermon, 2019).
Study guide
Where to start
Why does the score point toward regions of higher density, and how does Langevin dynamics use it, together with added noise, to turn noise into samples?
How to study this pagePredict · Check · Generalize · Continue
Compare what the notebook demo shows with the key equation here and with the papers cited below.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
The newer notebook covers the same concept and has an interactive demo.
Why It Matters for Modern Models
- Score functions underlie diffusion models: the network trained at each noise level is, up to scaling, an estimate of the score of the noised data distribution (Song & Ermon, 2019).
- This is why diffusion training is a regression problem: the best possible noise prediction is , a rescaled score.
- Energy-based models and diffusion models meet here: both can be trained through the score, which does not depend on the intractable normalizing constant.
Questions to Think About
- Why does a denoiser that predicts give the score through Tweedie's formula, ?
- Why can score matching avoid the partition function entirely, and what does a model trained only on gradients of log p fail to tell you about p itself?
Interactive Demo
The interactive demo for this concept is in the newer notebook.
Core Math
If you prefer intuition first, try the demo in the newer notebook, then come back for the math.
The score of a density is the gradient of its logarithm with respect to the input:
If , the score is : the normalizing constant drops out.
Score matching fits a model without knowing or the true score. After integration by parts, the objective needs only samples from the data (Hyvärinen, 2005):
The trace term is expensive in high dimensions, which motivates the denoising form.
Denoising score matching adds Gaussian noise, with , and regresses onto the score of the noise kernel (Vincent, 2011):
The regression target is noisy, but the minimizer is its conditional mean given , which equals the score of the noised data distribution, .
Tweedie's formula connects this to denoising (Efron, 2011):
so the best denoiser and the score of the noised distribution determine each other.