Flow Matching: A Visual Introduction
6 months ago
- #generative models
- #machine learning
- #flow matching
- Flow Matching (FM) is a technique for training generative models by learning to transport samples from a simple distribution (e.g., Gaussian noise) to a complex target distribution (e.g., images, videos).
- The post demonstrates a toy example where a 1D Gaussian noise distribution is mapped to a bimodal target distribution using linear flow matching.
- The flow matching model predicts a velocity field that describes how to move samples from the noise distribution to the target distribution over time steps t ∈ [0, 1].
- Training involves minimizing the expected reconstruction error of the velocity field using straight-line reference paths between noise and target samples.
- The model is implemented as a simple neural network trained with gradient-based optimization (Adam optimizer) to predict the velocity field.
- At inference, samples are generated by integrating the learned velocity field using Euler integration from noise samples to target samples.
- Visualizations include the learned velocity field, path densities, and comparisons between the target distribution and reconstructed samples.
- Flow matching can be extended to more complex distributions and higher dimensions, though it requires more sophisticated models and sampling strategies.