Intro

Diffusion models are unsupervised probabilistic generative models inspired by non-equilibrium thermodynamics. They have 2 major processes:

  1. Forward diffusion process: Adding noise to data until the result is no different to random noise.
  2. Reverse diffusion process: Learning to reverse the diffusion process to reconstruct the original data from the noise obtained from forward diffusion process.

Generative Models Overview

Forward diffusion process

Given an image, which we call , the forward diffusion process is in which we sample a series of Gaussian noise and add them to the image in steps, producing a sequence of noisy samples . Eventually when , is equivalent to an isotropic Gaussian distribution, which will be proved later.

Let’s assume each step can be pictured like this:

Each step is controlled by a variance schedule .

In this equation, we can tell is the mean and is the variance. While the mean is smaller than 1, each step will shrink the value for each pixel in the image, and then add a noise with variance equals .

At the beginning, small noise can cause considerable impact, so we can make the small to keep the gap between and closer. And with time pass by, we will need bigger to ensure changes could be tell. We can set and .

It’s not difficult to find that only depends on , therefore the forward diffusion process is Markov process.

Re-parameterization

Before diving into the calculation, it’s better to introduce re-parameterization, which will be used during the calculation.

Let’s assume a random value , let , then $x$ can be re-parameterized as .

Re-parameterization can transfer the randomicity from to , which can not only simplify the calculation, but make the reverse diffusion process differentiable.

Proof

Let , .

Re-parameterize the equation (1) we can get:

Considering , we get:

when , we get:

Reverse diffusion Process

If we can reverse the forward diffusion process, we will be able to recreate the origin image from the Gaussian noise. But we cannot easily estimate because it needs to use the entire dataset. Therefore, we need to learn a model $p_{\theta}$ to approximate these conditional probabilities in order to run the reverse diffusion process.

Now the problem is how to learn the model .

It is noteworthy that the reverse conditional probability is tractable when conditioned on :

Using Bayes’ rule, we have:

From the forward diffusion process, we can get:

Combine the result above and because we only concern , we have:

where is some function not involving and details are omitted. Following the standard Gaussian density function, the mean and variance can be parameterized as follows:

From (2) we can represent , and plug it into the above equation and obtain:

References

  1. What are Diffusion Models? | Lil’Log (lilianweng.github.io)
  2. 扩散模型/Diffusion Model原理讲解