azula.denoise¶
Denoisers, parametrizations and training objectives.
For a distribution \(p(X)\) over \(\mathbb{R}^D\) and a perturbation kernel
the goal of a denoiser is to predict \(X\) given \(X_t\), that is to infer the posterior distribution
A denoiser is therefore an approximation \(q_\phi(X \mid X_t)\) of the posterior \(p(X \mid X_t)\) and its objective is to minimize the Kullback-Leibler (KL) divergence
For most use cases, it is enough to estimate the mean \(\mathbb{E}[X \mid x_t]\) of the posterior \(p(X \mid x_t)\), in which case \(q_\phi(X \mid x_t)\) should have mean \(\mu_\phi(x_t) \approx \mathbb{E}[X \mid x_t]\).
Classes¶
Abstract posterior \(q_\phi(X \mid x_t)\). |
|
Creates a Dirac delta posterior \(\delta(X - \mu)\). |
|
Creates a Gaussian posterior \(\mathcal{N}(X \mid \mu, \sigma^2)\). |
|
Abstract denoiser module. |
|
Creates an analytical Gaussian denoiser. |
|
Creates a denoiser with simple preconditioning. |
|
Creates a Gaussian denoiser with EDM-style preconditioning. |
Descriptions¶
- class azula.denoise.DiracPosterior(mean)¶[source]
Creates a Dirac delta posterior \(\delta(X - \mu)\).
- Parameters:
mean (Tensor) – The mean \(\mu\), with shape \((*)\).
- class azula.denoise.GaussianPosterior(mean, var)¶[source]
Creates a Gaussian posterior \(\mathcal{N}(X \mid \mu, \sigma^2)\).
- Parameters:
- class azula.denoise.GaussianDenoiser(mean, cov, schedule)¶[source]
Creates an analytical Gaussian denoiser.
Let \(X \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(X_t \sim \mathcal{N}(X, \Sigma_t)\), then
\[X \mid X_t \sim \mathcal{N} \left( \bar{\mu}, \bar{\Sigma} \right)\]with
\[\begin{split}\bar{\mu} & = \mu_x + \Sigma_x \left( \Sigma_x + \Sigma_t \right)^{-1} (X_t - \mu_x) \\ \bar{\Sigma} & = \left( \Sigma_x^{-1} + \Sigma_t^{-1} \right)^{-1}\end{split}\]References
Bayesian Filtering and Smoothing (Särkkä, 2013)- Parameters:
mean (Tensor) – The mean vector \(\mu_x\), with shape \((N_1, ..., N_d)\).
cov (Covariance) – The covariance matrix \(\Sigma_x\), with shape \((N_1, ..., N_d, N_1, \dots, N_d)\).
- class azula.denoise.SimpleDenoiser(backbone, schedule)¶[source]
Creates a denoiser with simple preconditioning.
\[\mu_\phi(x_t) = b_\phi(c_\mathrm{in}(t) \, x_t, c_\mathrm{time}(t))\]The preconditioning coefficients make the backbone independent of the noise schedule. Therefore, the latter can be replaced at any time.
\[\begin{split}c_\mathrm{in}(t) & = \frac{1}{\sqrt{\alpha_t^2 + \sigma_t^2}} \\ c_\mathrm{time}(t) & = \log \frac{\sigma_t}{\alpha_t}\end{split}\]- Parameters:
- forward(x_t, t, **kwargs)¶[source]
- Parameters:
- Returns:
The Dirac delta \(\delta(X - \mu_\phi(x_t))\).
- Return type:
- class azula.denoise.KarrasDenoiser(backbone, schedule)¶[source]
Creates a Gaussian denoiser with EDM-style preconditioning.
\[\mu_\phi(x_t) = c_\mathrm{skip}(t) \, x_t + c_\mathrm{out}(t) \, b_\phi(c_\mathrm{in}(t) \, x_t, c_\mathrm{time}(t))\]The preconditioning coefficients are generalized to take the scale \(\alpha_t\) into account.
\[\begin{split}c_\mathrm{in}(t) & = \frac{1}{\sqrt{\alpha_t^2 + \sigma_t^2}} \\ c_\mathrm{out}(t) & = \frac{\sigma_t}{\sqrt{\alpha_t^2 + \sigma_t^2}} \\ c_\mathrm{skip}(t) & = \frac{\alpha_t}{\alpha_t^2 + \sigma_t^2} \\ c_\mathrm{time}(t) & = \log \frac{\sigma_t}{\alpha_t}\end{split}\]References
Elucidating the Design Space of Diffusion-Based Generative Models (Karras et al., 2022)- Parameters:
- forward(x_t, t, **kwargs)¶[source]
- Parameters:
- Returns:
The Dirac delta \(\delta(X - \mu_\phi(x_t))\).
- Return type: