azula.guidance.cfg¶
Classifier-free guidance (CFG) internals.
References
Classifier-Free Diffusion Guidance (Ho et al., 2022)
Classes¶
Creates a CFG denoiser module. |
Descriptions¶
- class azula.guidance.cfg.CFGDenoiser(denoiser)¶
Creates a CFG denoiser module.
- Parameters:
denoiser (GaussianDenoiser) – A Gaussian denoiser.
- forward(x_t, t, positive, negative={}, guidance=1.0, **kwargs)¶
- Parameters:
x_t (Tensor) – A noisy tensor \(x_t\), with shape \((B, *)\).
t (Tensor) – The time \(t\), with shape \(()\) or \((B)\).
positive (Dict[str, Any]) – The positive label \(c_+\) as a dictionary of keyword arguments.
negative (Dict[str, Any]) – The negative label \(c_-\) as a dictionary of keyword arguments.
guidance (float | Tensor) – The classifier-free guidance strength \(\omega \in \mathbb{R}_+\).
kwargs – Optional keyword arguments.
- Returns:
The Gaussian \(\mathcal{N}(X \mid \mu_\phi(x_t \mid c), \Sigma_\phi(x_t \mid c))\).
- Return type: