Guidance
In Diffusion Models, guidance mechanisms control how much importance the model gives to the conditioning information, at the cost of sample diversity. The two most prevalent forms of guidance are Classifier Guidance and Classifier-Free Guidance. As of right now, Modular Diffusion only ships with the latter, but will support both in an upcoming release.
Classifier-free guidance
Classifier-free guidance was introduced in Ho & Salimans. (2022) where it was found to produce higher fidelity samples in conditional Diffusion Models. It modifies the diffusion process as follows:
- During training, a random subset of the batch labels are dropped, i.e., replaced with 0, before each epoch.
- During sampling, predicted values are computed according to
where is a scalar parameter that controls the strength of the guidance signal.
Parameters
dropout
-> Percentage of labels dropped during training.strength
-> Strength of the guidance signal .
Example
from diffusion.guidance import ClassifierFree
guidance = ClassifierFree(dropout=0.1, strength=2)
Classifier guidance
This guidance module is currently in development.
If you spot any typo or technical imprecision, please submit an issue or pull request to the library's GitHub repository .