Diffusion model

3,677 words · about 18 min read · Deep Learning

In machine learning, diffusion models, also known as diffusion-based generative models or score-based generative models, are a class of latent variable generative models. A diffusion model consists of two major components: the forward diffusion process, and the reverse sampling process. The goal of diffusion models is to learn a diffusion process for a given dataset, such that the process can generate new elements that are distributed similarly as the original dataset. A diffusion model models data as generated by a diffusion process, whereby a new datum performs a random walk with drift through the space of all possible data. A trained diffusion model can be sampled in many ways, with different efficiency and quality. There are various equivalent formalisms, including Markov chains, denoising diffusion probabilistic models, noise conditioned score networks, and stochastic differential equations. They are typically trained using variational inference. The model responsible for denoising is typically called its "backbone". The backbone may be of any kind, but they are typically U-nets or transformers. As of 2024, diffusion models are mainly used for computer vision tasks, including image denoising, inpainting, super-resolution, image generation, and video generation. These typically involve training a neural network to sequentially denoise images blurred with Gaussian noise. The model is trained to reverse the process of adding noise to an image. After training to convergence, it can be used for image generation by starting with an image composed of random noise, and applying the network iteratively to denoise the image. Diffusion-based image generators have seen widespread commercial interest, such as Stable Diffusion and DALL-E. These models typically combine diffusion models with other models, such as text-encoders and cross-attention modules to allow text-conditioned generation. Other than computer vision, diffusion models have also found applications in natural language processing such as text generation and summarization, sound generation, and reinforcement learning.

Denoising diffusion model

Non-equilibrium thermodynamics

Diffusion models were introduced in 2015 as a method to train a model that can sample from a highly complex probability distribution. They used techniques from non-equilibrium thermodynamics, especially diffusion. Consider, for example, how one might model the distribution of all naturally occurring photos. Each image is a point in the space of all images, and the distribution of naturally occurring photos is a "cloud" in space, which, by repeatedly adding noise to the images, diffuses out to the rest of the image space, until the cloud becomes all but indistinguishable from a Gaussian distribution

N

( 0 , I )

{\displaystyle {\mathcal {N}}(0,I)}

. A model that can approximately undo the diffusion can then be used to sample from the original distribution. This is studied in "non-equilibrium" thermodynamics, as the starting distribution is not in equilibrium, unlike the final distribution. The equilibrium distribution is the Gaussian distribution

N

( 0 , I )

{\displaystyle {\mathcal {N}}(0,I)}

, with pdf

ρ ( x ) ∝

e

1 2

‖ x

2

{\displaystyle \rho (x)\propto e^{-{\frac {1}{2}}\|x\|^{2}}}

. This is just the Maxwell–Boltzmann distribution of particles in a potential well

V ( x ) =

1 2

‖ x

2

{\displaystyle V(x)={\frac {1}{2}}\|x\|^{2}}

at temperature 1. The initial distribution, being very much out of equilibrium, would diffuse towards the equilibrium distribution, making biased random steps that are a sum of pure randomness (like a Brownian walker) and gradient descent down the potential well. The randomness is necessary: if the particles were to undergo only gradient descent, then they will all fall to the origin, collapsing the distribution.

Denoising Diffusion Probabilistic Model (DDPM)

The 2020 paper proposed the Denoising Diffusion Probabilistic Model (DDPM), which improves upon the previous method by variational inference.

Forward diffusion

To present the model, some notation is required.

β

1

, . . . ,

β

T

∈ ( 0 , 1 )

{\displaystyle \beta _{1},...,\beta _{T}\in (0,1)}

are fixed constants.

α

t

:= 1 −

β

t

{\displaystyle \alpha _{t}:=1-\beta _{t}}

α ¯

t

:=

α

1

α

t

{\displaystyle {\bar {\alpha }}_{t}:=\alpha _{1}\cdots \alpha _{t}}

σ

t

:=

1 −

α ¯

t

{\displaystyle \sigma _{t}:={\sqrt {1-{\bar {\alpha }}_{t}}}}

σ ~

t

:=

σ

t − 1

σ

t

β

t

{\displaystyle {\tilde {\sigma }}_{t}:={\frac {\sigma _{t-1}}{\sigma _{t}}}{\sqrt {\beta _{t}}}}

μ ~

t

(

x

t

,

x

0

) :=

α

t

( 1 −

α ¯

t − 1

)

x

t

+

α ¯

t − 1

( 1 −

α

t

)

x

0

σ

t

2

{\displaystyle {\tilde {\mu }}_{t}(x_{t},x_{0}):={\frac {{\sqrt {\alpha _{t}}}(1-{\bar {\alpha }}_{t-1})x_{t}+{\sqrt {{\bar {\alpha }}_{t-1}}}(1-\alpha _{t})x_{0}}{\sigma _{t}^{2}}}}

N

( μ , Σ )

{\displaystyle {\mathcal {N}}(\mu ,\Sigma )}

is the normal distribution with mean

μ

{\displaystyle \mu }

and variance

Σ

{\displaystyle \Sigma }

, and

N

( x

|

μ , Σ )

{\displaystyle {\mathcal {N}}(x|\mu ,\Sigma )}

is the probability density at

x

{\displaystyle x}

. A vertical bar denotes conditioning. A forward diffusion process starts at some starting point

x

0

∼ q

{\displaystyle x_{0}\sim q}

, where

q

{\displaystyle q}

is the probability distribution to be learned, then repeatedly adds noise to it by

x

t

=

1 −

β

t

x

t − 1

+

β

t

z

t

{\displaystyle x_{t}={\sqrt {1-\beta _{t}}}x_{t-1}+{\sqrt {\beta _{t}}}z_{t}}

where

z

1

, . . . ,

z

T

{\displaystyle z_{1},...,z_{T}}

are IID (Independent and identically distributed random variables) samples from

N

( 0 , I )

{\displaystyle {\mathcal {N}}(0,I)}

. The coefficients

1 −

β

t

{\displaystyle {\sqrt {1-\beta _{t}}}}

and

β

t

{\displaystyle {\sqrt {\beta _{t}}}}

ensure that

Var

(

X

t

) = I

{\displaystyle {\mbox{Var}}(X_{t})=I}

assuming that

Var

(

X

0

) = I

{\displaystyle {\mbox{Var}}(X_{0})=I}

. The values of

β

t

{\displaystyle \beta _{t}}

are chosen such that for any starting distribution of

x

0

{\displaystyle x_{0}}

, if it has finite second moment, then

lim

t → ∞

x

t

|

x

0

{\displaystyle \lim _{t\to \infty }x_{t}|x_{0}}

converges to

N

( 0 , I )

{\displaystyle {\mathcal {N}}(0,I)}

. The entire diffusion process then satisfies

q (

x

0 : T

) = q (

x

0

) q (

x

1

|

x

0

) ⋯ q (

x

T

|

x

T − 1

) = q (

x

0

)

N

(

x

1

|

α

1

x

0

,

β

1

I ) ⋯

N

(

x

T

|

α

T

x

T − 1

,

β

T

I )

{\displaystyle q(x_{0:T})=q(x_{0})q(x_{1}|x_{0})\cdots q(x_{T}|x_{T-1})=q(x_{0}){\mathcal {N}}(x_{1}|{\sqrt {\alpha _{1}}}x_{0},\beta _{1}I)\cdots {\mathcal {N}}(x_{T}|{\sqrt {\alpha _{T}}}x_{T-1},\beta _{T}I)}

or

ln ⁡ q (

x

0 : T

) = ln ⁡ q (

x

0

) −

t = 1

T

1

2

β

t

x

t

1 −

β

t

x

t − 1

2

+ C

{\displaystyle \ln q(x_{0:T})=\ln q(x_{0})-\sum _{t=1}^{T}{\frac {1}{2\beta _{t}}}\|x_{t}-{\sqrt {1-\beta _{t}}}x_{t-1}\|^{2}+C}

where

C

{\displaystyle C}

is a normalization constant and often omitted. In particular, we note that

x

1 : T

|

x

0

{\displaystyle x_{1:T}|x_{0}}

is a Gaussian process, which affords us considerable freedom in reparameterization. For example, by standard manipulation with Gaussian process,

x

t

|

x

0

∼ N

(

α ¯

t

x

0

,

σ

t

2

I

)

{\displaystyle x_{t}|x_{0}\sim N\left({\sqrt {{\bar {\alpha }}_{t}}}x_{0},\sigma _{t}^{2}I\right)}

x

t − 1

|

x

t

,

x

0

N

(

μ ~

t

(

x

t

,

x

0

) ,

σ ~

t

2

I )

{\displaystyle x_{t-1}|x_{t},x_{0}\sim {\mathcal {N}}({\tilde {\mu }}_{t}(x_{t},x_{0}),{\tilde {\sigma }}_{t}^{2}I)}

In particular, notice that for large

t

{\displaystyle t}

, the variable

x

t

|

x

0

∼ N

(

α ¯

t

x

0

,

σ

t

2

I

)

{\displaystyle x_{t}|x_{0}\sim N\left({\sqrt {{\bar {\alpha }}_{t}}}x_{0},\sigma _{t}^{2}I\right)}

converges to

N

( 0 , I )

{\displaystyle {\mathcal {N}}(0,I)}

. That is, after a long enough diffusion process, we end up with some

x

T

{\displaystyle x_{T}}

that is very close to

N

( 0 , I )

{\displaystyle {\mathcal {N}}(0,I)}

, with all traces of the original

x

0

∼ q

{\displaystyle x_{0}\sim q}

gone. For example, since

x

t

|

x

0

∼ N

(

α ¯

t

x

0

,

σ

t

2

I

)

{\displaystyle x_{t}|x_{0}\sim N\left({\sqrt {{\bar {\alpha }}_{t}}}x_{0},\sigma _{t}^{2}I\right)}

we can sample

x

t

|

x

0

{\displaystyle x_{t}|x_{0}}

directly "in one step", instead of going through all the intermediate steps

x

1

,

x

2

, . . . ,

x

t − 1

{\displaystyle x_{1},x_{2},...,x_{t-1}}

.

Backward diffusion

The key idea of DDPM is to use a neural network parametrized by

θ

{\displaystyle \theta }

. The network takes in two arguments

x

t

, t

{\displaystyle x_{t},t}

, and outputs a vector

μ

θ

(

x

t

, t )

{\displaystyle \mu _{\theta }(x_{t},t)}

and a matrix

Σ

θ

(

x

t

, t )

{\displaystyle \Sigma _{\theta }(x_{t},t)}

, such that each step in the forward diffusion process can be approximately undone by

x

t − 1

N

(

μ

θ

(

x

t

, t ) ,

Σ

θ

(

x

t

, t ) )

{\displaystyle x_{t-1}\sim {\mathcal {N}}(\mu _{\theta }(x_{t},t),\Sigma _{\theta }(x_{t},t))}

. This then gives us a backward diffusion process

p

θ

{\displaystyle p_{\theta }}

defined by

p

θ

(

x

T

) =

N

(

x

T

|

0 , I )

{\displaystyle p_{\theta }(x_{T})={\mathcal {N}}(x_{T}|0,I)}

p

θ

(

x

t − 1

|

x

t

) =

N

(

x

t − 1

|

μ

θ

(

x

t

, t ) ,

Σ

θ

(

x

t

, t ) )

{\displaystyle p_{\theta }(x_{t-1}|x_{t})={\mathcal {N}}(x_{t-1}|\mu _{\theta }(x_{t},t),\Sigma _{\theta }(x_{t},t))}

The goal now is to learn the parameters

θ

{\displaystyle \theta }

such that

p

θ

(

x

0

)

{\displaystyle p_{\theta }(x_{0})}

is as close to

q (

x

0

)

{\displaystyle q(x_{0})}

as possible. To do that, we use maximum likelihood estimation with variational inference.

Variational inference

The ELBO inequality states that

ln ⁡

p

θ

(

x

0

) ≥

E

x

1 : T

∼ q ( ⋅

|

x

0

)

[ ln ⁡

p

θ

(

x

0 : T

) − ln ⁡ q (

x

1 : T

|

x

0

) ]

{\displaystyle \ln p_{\theta }(x_{0})\geq E_{x_{1:T}\sim q(\cdot |x_{0})}[\ln p_{\theta }(x_{0:T})-\ln q(x_{1:T}|x_{0})]}

, and taking one more expectation, we get

E

x

0

∼ q

[ ln ⁡

p

θ

(

x

0

) ] ≥

E

x

0 : T

∼ q

[ ln ⁡

p

θ

(

x

0 : T

) − ln ⁡ q (

x

1 : T

|

x

0

) ]

{\displaystyle E_{x_{0}\sim q}[\ln p_{\theta }(x_{0})]\geq E_{x_{0:T}\sim q}[\ln p_{\theta }(x_{0:T})-\ln q(x_{1:T}|x_{0})]}

We see that maximizing the quantity on the right would give us a lower bound on the likelihood of observed data. This allows us to perform variational inference. Define the loss function

L ( θ ) := −

E

x

0 : T

∼ q

[ ln ⁡

p

θ

(

x

0 : T

) − ln ⁡ q (

x

1 : T

|

x

0

) ]

{\displaystyle L(\theta ):=-E_{x_{0:T}\sim q}[\ln p_{\theta }(x_{0:T})-\ln q(x_{1:T}|x_{0})]}

and now the goal is to minimize the loss by stochastic gradient descent. The expression may be simplified to

L ( θ ) =

t = 1

T

E

x

t − 1

,

x

t

∼ q

[ − ln ⁡

p

θ

(

x

t − 1

|

x

t

) ] +

E

x

0

∼ q

[

D

K L

( q (

x

T

|

x

0

) ‖

p

θ

(

x

T

) ) ] + C

{\displaystyle L(\theta )=\sum _{t=1}^{T}E_{x_{t-1},x_{t}\sim q}[-\ln p_{\theta }(x_{t-1}|x_{t})]+E_{x_{0}\sim q}[D_{KL}(q(x_{T}|x_{0})\|p_{\theta }(x_{T}))]+C}

where

C

{\displaystyle C}

does not depend on the parameter, and thus can be ignored. Since

p

θ

(

x

T

) =

N

(

x

T

|

0 , I )

{\displaystyle p_{\theta }(x_{T})={\mathcal {N}}(x_{T}|0,I)}

also does not depend on the parameter, the term

E

x

0

∼ q

[

D

K L

( q (

x

T

|

x

0

) ‖

p

θ

(

x

T

) ) ]

{\displaystyle E_{x_{0}\sim q}[D_{KL}(q(x_{T}|x_{0})\|p_{\theta }(x_{T}))]}

can also be ignored. This leaves just

L ( θ ) =

t = 1

T

L

t

{\displaystyle L(\theta )=\sum _{t=1}^{T}L_{t}}

with

L

t

=

E

x

t − 1

,

x

t

∼ q

[ − ln ⁡

p

θ

(

x

t − 1

|

x

t

) ]

{\displaystyle L_{t}=E_{x_{t-1},x_{t}\sim q}[-\ln p_{\theta }(x_{t-1}|x_{t})]}

to be minimized.

Noise prediction network

Since

x

t − 1

|

x

t

,

x

0

N

(

μ ~

t

(

x

t

,

x

0

) ,

σ ~

t

2

I )

{\displaystyle x_{t-1}|x_{t},x_{0}\sim {\mathcal {N}}({\tilde {\mu }}_{t}(x_{t},x_{0}),{\tilde {\sigma }}_{t}^{2}I)}

, this suggests that we should use

μ

θ

(

x

t

, t ) =

μ ~

t

(

x

t

,

x

0

)

{\displaystyle \mu _{\theta }(x_{t},t)={\tilde {\mu }}_{t}(x_{t},x_{0})}

; however, the network does not have access to

x

0

{\displaystyle x_{0}}

, and so it has to estimate it instead. Now, since

x

t

|

x

0

∼ N

(

α ¯

t

x

0

,

σ

t

2

I

)

{\displaystyle x_{t}|x_{0}\sim N\left({\sqrt {{\bar {\alpha }}_{t}}}x_{0},\sigma _{t}^{2}I\right)}

, we may write

x

t

=

α ¯

t

x

0

+

σ

t

z

{\displaystyle x_{t}={\sqrt {{\bar {\alpha }}_{t}}}x_{0}+\sigma _{t}z}

, where

z

{\displaystyle z}

is some unknown Gaussian noise. Now we see that estimating

x

0

{\displaystyle x_{0}}

is equivalent to estimating

z

{\displaystyle z}

. Therefore, let the network output a noise vector

ϵ

θ

(

x

t

, t )

{\displaystyle \epsilon _{\theta }(x_{t},t)}

, and let it predict

μ

θ

(

x

t

, t ) =

μ ~

t

(

x

t

,

x

t

σ

t

ϵ

θ

(

x

t

, t )

α ¯

t

)

=

x

t

ϵ

θ

(

x

t

, t )

β

t

/

σ

t

α

t

{\displaystyle \mu _{\theta }(x_{t},t)={\tilde {\mu }}_{t}\left(x_{t},{\frac {x_{t}-\sigma _{t}\epsilon _{\theta }(x_{t},t)}{\sqrt {{\bar {\alpha }}_{t}}}}\right)={\frac {x_{t}-\epsilon _{\theta }(x_{t},t)\beta _{t}/\sigma _{t}}{\sqrt {\alpha _{t}}}}}

It remains to design

Σ

θ

(

x

t

, t )

{\displaystyle \Sigma _{\theta }(x_{t},t)}

. The DDPM paper suggested not learning it (since it resulted in "unstable training and poorer sample quality"), but fixing it at some value

Σ

θ

(

x

t

, t ) =

ζ

t

2

I

{\displaystyle \Sigma _{\theta }(x_{t},t)=\zeta _{t}^{2}I}

, where either

ζ

t

2

=

β

t

or

σ ~

t

2

{\displaystyle \zeta _{t}^{2}=\beta _{t}{\text{ or }}{\tilde {\sigma }}_{t}^{2}}

yielded similar performance. With this, the loss simplifies to

L

t

=

β

t

2

2

α

t

σ

t

2

ζ

t

2

E

x

0

∼ q ; z ∼

N

( 0 , I )

[

ϵ

θ

(

x

t

, t ) − z

2

]

+ C

{\displaystyle L_{t}={\frac {\beta _{t}^{2}}{2\alpha _{t}\sigma _{t}^{2}\zeta _{t}^{2}}}E_{x_{0}\sim q;z\sim {\mathcal {N}}(0,I)}\left[\left\|\epsilon _{\theta }(x_{t},t)-z\right\|^{2}\right]+C}

which may be minimized by stochastic gradient descent. The paper noted empirically that an even simpler loss function

L

s i m p l e , t

=

E

x

0

∼ q ; z ∼

N

( 0 , I )

[

ϵ

θ

(

x

t

, t ) − z

2

]

{\displaystyle L_{simple,t}=E_{x_{0}\sim q;z\sim {\mathcal {N}}(0,I)}\left[\left\|\epsilon _{\theta }(x_{t},t)-z\right\|^{2}\right]}

resulted in better models.

Backward diffusion process

After a noise prediction network is trained, it can be used for generating data points in the original distribution in a loop as follows:

Compute the noise estimate

ϵ ←

ϵ

θ

(

x

t

, t )

{\displaystyle \epsilon \leftarrow \epsilon _{\theta }(x_{t},t)}

Compute the original data estimate

x ~

0

← (

x

t

σ

t

ϵ )

/

α ¯

t

{\displaystyle {\tilde {x}}_{0}\leftarrow (x_{t}-\sigma _{t}\epsilon )/{\sqrt {{\bar {\alpha }}_{t}}}}

Sample the previous data

x

t − 1

N

(

μ ~

t

(

x

t

,

x ~

0

) ,

σ ~

t

2

I )

{\displaystyle x_{t-1}\sim {\mathcal {N}}({\tilde {\mu }}_{t}(x_{t},{\tilde {x}}_{0}),{\tilde {\sigma }}_{t}^{2}I)}

Change time

t ← t − 1

{\displaystyle t\leftarrow t-1}

Score-based generative model

Score-based generative model is another formulation of diffusion modelling. They are also called noise conditional score network (NCSN) or score-matching with Langevin dynamics (SMLD).

Score matching

The idea of score functions

Consider the problem of image generation. Let

x

{\displaystyle x}

represent an image, and let

q ( x )

{\displaystyle q(x)}

be the probability distribution over all possible images. If we have

q ( x )

{\displaystyle q(x)}

itself, then we can say for certain how likely a certain image is. However, this is intractable in general. Most often, we are uninterested in knowing the absolute probability of a certain image. Instead, we are usually only interested in knowing how likely a certain image is compared to its immediate neighbors — e.g. how much more likely is an image of cat compared to some small variants of it? Is it more likely if the image contains two whiskers, or three, or with some Gaussian noise added? Consequently, we are actually quite uninterested in

q ( x )

{\displaystyle q(x)}

itself, but rather,

x

ln ⁡ q ( x )

{\displaystyle \nabla _{x}\ln q(x)}

. This has two major effects:

One, we no longer need to normalize

q ( x )

{\displaystyle q(x)}

, but can use any

q ~

( x ) = C q ( x )

{\displaystyle {\tilde {q}}(x)=Cq(x)}

, where

C = ∫

q ~

( x ) d x > 0

{\displaystyle C=\int {\tilde {q}}(x)dx>0}

is any unknown constant that is of no concern to us. Two, we are comparing

q ( x )

{\displaystyle q(x)}

neighbors

q ( x + d x )

{\displaystyle q(x+dx)}

, by

q ( x )

q ( x + d x )

=

e

− ⟨

x

ln ⁡ q , d x ⟩

{\displaystyle {\frac {q(x)}{q(x+dx)}}=e^{-\langle \nabla _{x}\ln q,dx\rangle }}

Let the score function be

s ( x ) :=

x

ln ⁡ q ( x )

{\displaystyle s(x):=\nabla _{x}\ln q(x)}

; then consider what we can do with

s ( x )

{\displaystyle s(x)}

. As it turns out,

s ( x )

{\displaystyle s(x)}

allows us to sample from

q ( x )

{\displaystyle q(x)}

using thermodynamics. Specifically, if we have a potential energy function

U ( x ) = − ln ⁡ q ( x )

{\displaystyle U(x)=-\ln q(x)}

, and a lot of particles in the potential well, then the distribution at thermodynamic equilibrium is the Boltzmann distribution

q

U

( x ) ∝

e

− U ( x )

/

k

B

T

= q ( x

)

1

/

k

B

T

{\displaystyle q_{U}(x)\propto e^{-U(x)/k_{B}T}=q(x)^{1/k_{B}T}}

. At temperature

k

B

T = 1

{\displaystyle k_{B}T=1}

, the Boltzmann distribution is exactly

q ( x )

{\displaystyle q(x)}

. Therefore, to model

q ( x )

{\displaystyle q(x)}

, we may start with a particle sampled at any convenient distribution (such as the standard Gaussian distribution), then simulate the motion of the particle forwards according to the Langevin equation

d

x

t

= −

x

t

U (

x

t

) d t + d

W

t

{\displaystyle dx_{t}=-\nabla _{x_{t}}U(x_{t})dt+dW_{t}}

and the Boltzmann distribution is, by Fokker-Planck equation, the unique thermodynamic equilibrium. So no matter what distribution

x

0

{\displaystyle x_{0}}

has, the distribution of

x

t

{\displaystyle x_{t}}

converges in distribution to

q

{\displaystyle q}

as

t → ∞

{\displaystyle t\to \infty }

.

Learning the score function

Given a density

q

{\displaystyle q}

, we wish to learn a score function approximation

f

θ

≈ ∇ ln ⁡ q

{\displaystyle f_{\theta }\approx \nabla \ln q}

. This is score matching. Typically, score matching is formalized as minimizing Fisher divergence function

E

q

[ ‖

f

θ

( x ) − ∇ ln ⁡ q ( x )

2

]

{\displaystyle E_{q}[\|f_{\theta }(x)-\nabla \ln q(x)\|^{2}]}

. By expanding the integral, and performing an integration by parts,

E

q

[ ‖

f

θ

( x ) − ∇ ln ⁡ q ( x )

2

] =

E

q

[ ‖

f

θ

2

+ 2 ∇ ⋅

f

θ

] + C

{\displaystyle E_{q}[\|f_{\theta }(x)-\nabla \ln q(x)\|^{2}]=E_{q}[\|f_{\theta }\|^{2}+2\nabla \cdot f_{\theta }]+C}

giving us a loss function, also known as the Hyvärinen scoring rule, that can be minimized by stochastic gradient descent.

Annealing the score function

Suppose we need to model the distribution of images, and we want

x

0

N

( 0 , I )

{\displaystyle x_{0}\sim {\mathcal {N}}(0,I)}

, a white-noise image. Now, most white-noise images do not look like real images, so

q (

x

0

) ≈ 0

{\displaystyle q(x_{0})\approx 0}

for large swaths of

x

0

N

( 0 , I )

{\displaystyle x_{0}\sim {\mathcal {N}}(0,I)}

. This presents a problem for learning the score function, because if there are no samples around a certain point, then we can't learn the score function at that point. If we do not know the score function

x

t

ln ⁡ q (

x

t

)

{\displaystyle \nabla _{x_{t}}\ln q(x_{t})}

at that point, then we cannot impose the time-evolution equation on a particle:

d

x

t

=

x

t

ln ⁡ q (

x

t

) d t + d

W

t

{\displaystyle dx_{t}=\nabla _{x_{t}}\ln q(x_{t})dt+dW_{t}}

To deal with this problem, we perform annealing. If

q

{\displaystyle q}

is too different from a white-noise distribution, then progressively add noise until it is indistinguishable from one. That is, we perform a forward diffusion, then learn the score function, then use the score function to perform a backward diffusion.

Continuous diffusion processes

Forward diffusion process

Consider again the forward diffusion process, but this time in continuous time:

x

t

=

1 −

β

t

Source: Diffusion model on Wikipedia · CC BY-SA 4.0