Remebmer the forward step of the diffusion process from the previous notebook: $$ q(\mathbf{x}{1:T} \vert \mathbf{x}0) = \prod^T{t=1} q(\mathbf{x}t \vert \mathbf{x}{t-1}) , \quad q(x_t|x{t−1}) := \mathcal{N}(x_t; \sqrt{1 − \beta_t}x_{t−1}, \beta_tI) \tag{1} $$
We can rewrite the forward step using the reparameztrization trick as follows:
where
Using smaller and smaller time steps
In the limit of
Here,
Stochastic Differential Equations (SDEs) are a type of differential equation in which one or more of the terms is a stochastic process, resulting in a solution that is also a stochastic process. They are used to model systems that are influenced by random effects. The Slide from the CVPR tutorial on Denoising Diffusion based Models (https://cvpr2022-tutorial-diffusion-models.github.io/) below helps to understand the difference between ODEs and SDEs:
Comparison of ODEs and SDEs (from: https://cvpr2022-tutorial-diffusion-models.github.io/)To better understand SDEs, it's important to first understand the concept of a stochastic process. A stochastic process is a mathematical object usually defined as a collection of random variables. For example for a collection of random variables with respect to time you can think of something like the likelihood of a position or motion of a particle over time. In the context of SDEs, these random variables represent the evolution of a system of random values over time.
As a solution for a Stochastic Differential Equation, the diffusion process is a type of stochastic process that is commonly used to model the dynamics of continuously changing phenomena where randomness plays a role. We can use it where we want to model some form of random walk or noise component. In a diffusion process, the change in the system over time is governed by two components:
- Drift: This is the deterministic part of the process, which can be thought of as the "average" or "expected" direction in which the process moves. In an SDE, this is typically represented by a function of the current state and time.
- Diffusion: This is the stochastic part of the process, which represents random fluctuations around the drift. In an SDE, this is typically represented by a function of the current state and time, multiplied by a Wiener process or another type of stochastic process.
The most common example of a diffusion process is Brownian motion, also known as the Wiener process, which models the random motion of particles suspended in a fluid. In Brownian motion, the drift is zero, so the motion is entirely random, with the current velocity of a particle independent of its past velocities. As an example of Brownian motion, the following animation shows a large particle, that collides with a large set of other smaller particles (like a dust particle in the air) and moves in a random directions:
Brownian Motion (from: https://weelookang.blogspot.com/2010/06/ejs-open-source-brownian-motion-gas.html)In a more general diffusion process, the drift can be non-zero, so the process has a tendency to move in a certain direction, but there are still random fluctuations around this direction. For example with the SDE from above:
we have the following different parts of the general SDE of the form:
Where,
The diffusion term is responsible for the random fluctuations in the process
The deterministic part,
The deterministic drift part of the diffusion process pulls the data towards the mode of the data distribution. The stochastic diffusion part injects noise into the data. Because of the noise there is no unique path that the data takes. Instead, there is a family of curves that the data could take. The collection of all such curves gives a description of the data distribution. The image below helps to visualize this:
Visualizing the Forward Diffusion SDE(from: https://yang-song.net/blog/2021/score/)On the left we have samples of the data distribution (images of bedrooms). In the center we have the corresponding diffusion process. In red we can see actual sampled trajectories of the diffusion process. In blue to yellow we can see the a visualization of the probability density function over time. On the left side a simplified multimodal distribution like a Gaussian Mixture Model changing to a univariat Gaussian over time. We can see that there is a deterministic part which pulls the samples to the modes of the distribution and a stochastic part which injects noise making each trajectory unique. We can see that the diffusion process starts with the data distribution and ends with the unit Gaussian distribution.
If we can run this process in the reverse direction we could genereate data from the unit gaussian distribution. As shown in general by Brian Anderson in "Reverse-time diffusion equation models" (https://www.sciencedirect.com/science/article/pii/0304414982900515) and later by Yang Song for generative modeling in "Score-Based Generative Modeling through Stochastic Differential Equations" (https://arxiv.org/abs/2011.13456) we can run the diffusion process in reverse by solving the following SDE for the reverse time diffusion process:
Where,




