Menu Logo

Modular Diffusion

GitHub Discord PyPI

Noise Schedule

In Diffusion Models, the noise schedule dictates how much noise is added to the data at each time step. The noise schedule is typically defined as a function αt\alpha_t that maps a time step tt into a value αt[0,1]\alpha_t \in [0, 1]. Modular Diffusion comes with a growing set of prebuilt noise schedules.

Constant schedule

Constant noise schedule given by αt=k\alpha_t = k.

Parameters

  • steps -> Number of time steps TT.
  • value -> Constant value kk.

Example

from diffusion.schedule import Constant

schedule = Constant(1000, 0.995)

Visualization

Applying Gaussian noise to an image using the Constant schedule with T=1000T=1000 and k=0.995k=0.995 in equally spaced snapshots:

Image of a dog getting noisier at a constant rate.

Linear schedule

Linear noise schedule introduced in Ho et al. (2020) computed by linearly interpolating from α0\alpha_0 to αT\alpha_T.

Parameters

  • steps -> Number of time steps TT.
  • start -> Start value α0\alpha_0.
  • end -> End value αT\alpha_T.

Example

from diffusion.schedule import Linear

schedule = Linear(1000, 0.9999, 0.98)

Visualization

Applying Gaussian noise to an image using the Linear schedule with T=1000T=1000, α0=0.9999\alpha_0=0.9999 and αT=0.98\alpha_T=0.98 in equally spaced snapshots:

Image of a dog getting noisier at a linear rate.

Cosine schedule

Cosine noise schedule introduced in Nichol et al. (2021) which offers a more gradual noising process relative to the linear schedule. It is defined as αt=αˉtαˉt1\alpha_t = \frac{\bar{\alpha}_t}{\bar{\alpha}_{t-1}}, where:

  • αˉt=f(t)f(0)\bar{\alpha}_t=\frac{f(t)}{f(0)}
  • f(t)=cos(t/T+s1+sπ2)ef(t) = \cos(\frac{t/T+s}{1+s} \cdot \frac{\pi}{2})^e

Parameters

  • steps -> Number of time steps TT.
  • offset (default: 8e-3) -> Offset ss.
  • exponent (default: 2) -> Exponent ee.

Example

from diffusion.schedule import Cosine

schedule = Cosine(1000)

Visualization

Applying Gaussian noise to an image using the Cosine schedule with T=1000T=1000, s=8e3s=8e-3 and e=2e=2 in equally spaced snapshots:

Image of a dog getting noisier at a cosine rate.

Square root schedule

Square root noise schedule introduced in Li et al. (2022). It is defined as αt=αˉtαˉt1\alpha_t = \frac{\bar{\alpha}_t}{\bar{\alpha}_{t-1}}, where αˉt=1t/T+s\bar{\alpha}_t=1-\sqrt{t/T+s}.

Parameters

  • steps -> Number of time steps TT.
  • offset (default: 8e-3) -> Offset ss.

Example

from diffusion.schedule import Sqrt

schedule = Sqrt(1000)

Visualization

Applying Gaussian noise to an image using the Sqrt schedule with T=1000T=1000 and s=8e3s=8e-3 in equally spaced snapshots:

Image of a dog getting noisier at a sqrt rate.


If you spot any typo or technical imprecision, please submit an issue or pull request to the library's GitHub repository .