Member-only story

What is a Reverse Diffusion Model

Abdulkader Helwan
8 min readJan 2, 2024

--

Reverse diffusion models are a type of generative models that learn to invert a stochastic process that transforms data into noise. They are based on the theory of stochastic differential equations (SDEs), which describe the evolution of a random variable over time under the influence of some noise.

In this story, we will show what is a reverse diffusion model and help you implement one in Python.

High level visualization of one step from the reverse diffusion process

What is the Reverse Diffusion Model!

To build a reverse diffusion model, one needs to define a forward process that corrupts the data by adding noise and scaling down the signal at each step. This process can be seen as a discretization of an SDE that has a known analytical solution. The reverse process then tries to recover the original data from the noise by using a neural network to predict the parameters of a conditional Gaussian distribution at each step. The neural network takes as input the current noisy observation and the step number, and outputs the mean and variance (or covariance) of the Gaussian distribution. The reverse process can also be seen as a discretization of the reverse SDE that corresponds to the forward SDE.

How to Implement a Reverse Diffusion Model?

To implement a reverse diffusion model, one can use a variational inference framework to train the neural network. The objective is to maximize the evidence lower bound (ELBO), which is a lower bound on the log-likelihood of the data given the model. The ELBO can be computed by using the forward process as a proposal distribution and applying the reparameterization trick to sample from the conditional Gaussian distributions. The ELBO can be further improved by using a denoising score matching loss, which measures the discrepancy between the score functions of the data and the model¹.

There are many variants and extensions of reverse diffusion models, such as reflected diffusion models, and Gaussian mixture solvers, that aim to improve the sampling quality and efficiency. Reverse diffusion models have been shown to achieve state-of-the-art results on various generative tasks, such as image synthesis, super-resolution, inpainting, and style transfer.

--

--

Abdulkader Helwan
Abdulkader Helwan

No responses yet

Write a response