Skip to content
BIASED

Score matching

Block 1 of 8~2 min

The score: a gradient of log-density

The topic DDPM: reverse process and objective trained a network εθ(xt,t)\varepsilon_\theta(x_t, t) to predict the noise mixed into xtx_t, then generated images by calling it TT times. It ended with a claim still to be checked. Without x0x_0 the network cannot know which noise was added, so it learns the average E[ε∣xt]\mathbb E[\varepsilon \mid x_t] — and that average was said to be, up to a scale and a sign, the gradient of the log-density of noisy images. Why does that make noise prediction work so well? This topic builds the object behind the claim and then checks it.

The score of a density pp is

s(x)=∇xlog⁡p(x).s(x) = \nabla_x \log p(x).

It is a vector field. At every point x∈RDx \in \mathbb R^D it returns a vector of the same size as xx, pointing where log⁡p\log p grows fastest. On a slope it is long and points uphill; at a peak it is zero. A score model sθ(x)≈∇xlog⁡p(x)s_\theta(x) \approx \nabla_x \log p(x) is therefore a network from RD\mathbb R^D to RD\mathbb R^D, the same shape as a denoiser.

The derivative is taken with respect to the data xx, not the parameters. The score-function estimator in The reparameterization trick differentiated with respect to parameters; here the parameters stay fixed and the point moves.

The simplest case is a 1-D Gaussian. Its log-density (see Multivariate Gaussians) is a parabola in xx:

log⁡N(x; μ,σ2)=−(x−μ)22σ2−12log⁡(2πσ2).\log \mathcal N(x;\, \mu, \sigma^2) = -\frac{(x - \mu)^2}{2\sigma^2} - \tfrac12 \log\big(2\pi\sigma^2\big).

Its derivative in xx is the score of a Gaussian. The checks below ask you to take it.

Answers are saved on the server and tied to this browser until you sign in.