Abstract
Normalizing flows provide an elegant method for obtaining tractable density estimates from distributions by using invertible transformations. The main challenge is to improve the expressivity of the models while keeping the invertibility constraints intact. We propose to do so via the incorporation of localized self-attention. However, conventional self-attention mechanisms don't satisfy the requirements to obtain invertible flows and can't be naively incorporated into normalizing flows. To address this, we introduce a novel approach called Attentive Contractive Flow (ACF) which utilizes a special category of flow-based generative models - contractive flows. We demonstrate that ACF can be introduced into a variety of state of the art flow models in a plug-and-play manner. This is demonstrated to not only improve the representation power of these models (improving on the bits per dim metric), but also to results in significantly faster convergence in training them. Qualitative results, including interpolations between test images, demonstrate that samples are more realistic and capture local correlations in the data well. We evaluate the results further by performing perturbation analysis using AWGN demonstrating that ACF models (especially the dot-product variant) show better and more consistent resilience to additive noise.
Introduction
Generative modeling has seen significant progress through Generative Adversarial Networks (GANs) and Variational Autoencoders (VAEs). However, these models often lack the ability to provide exact probability density estimates. Normalizing Flows (NFs) address this by transforming a simple base distribution into a complex target distribution through a sequence of invertible mappings. Despite their theoretical appeal, NFs face a trade-off between expressivity and mathematical tractability. To maintain invertibility and a tractable Jacobian determinant, NFs are frequently limited to local operations like convolutions, which struggle to capture long-range dependencies.
Self-attention mechanisms, widely successful in Transformers, are ideal for capturing such global context but are not naturally invertible or Lipschitz-continuous. This paper introduces Attentive Contractive Flow (ACF), a framework that integrates global self-attention into normalizing flows by enforcing Lipschitz constraints, thereby enhancing model expressivity without sacrificing invertibility.
Methodology
ACF leverages Contractive Flows, such as iResNet and Residual Flows, which utilize residual blocks of the form $f(x) = x + g(x)$. For these blocks to be invertible via Banach’s Fixed Point Theorem, the function $g(x)$ must be a contraction with a Lipschitz constant less than 1.
The authors propose two methods to make self-attention Lipschitz-constrained:
- $L_2$ Self-Attention: Replacing the standard dot-product with $L_2$ distance, which has a bounded Lipschitz constant.
- Lipschitz Normalization: Scaling standard dot-product attention by its calculated upper-bound Lipschitz constant.
These modifications allow self-attention to be used as a "plug-and-play" module within the residual function $g(x)$, as illustrated in the comparison between standard Contractive Flows (CF) and the proposed Attentive Contractive Flows (ACF).
Experimental Results
The ACF framework was evaluated on several benchmarks, including MNIST, CIFAR10, ImageNet32/64, and CelebA-HQ64. The inclusion of self-attention consistently improved the Bits Per Dimension (BPD) metric across all datasets. For instance, on MNIST, ACF achieved 0.87 BPD compared to the 1.05 BPD baseline of iResNet.
Beyond final performance, a key finding was the impact on training dynamics. ACF models exhibited significantly faster convergence. By enabling the model to capture global correlations early on, the attention mechanism allows the flow to find the underlying data structure in fewer iterations.
Furthermore, ACF demonstrated superior robustness to Additive White Gaussian Noise (AWGN) and improved qualitative results in latent space interpolations, capturing local correlations more effectively than purely convolutional baselines.
Conclusion and Future Work
Attentive Contractive Flow successfully bridges the gap between the global modeling capabilities of self-attention and the strict invertibility requirements of normalizing flows. While the $O(N^2)$ complexity of self-attention remains a challenge for high-resolution images, the improvements in convergence speed and density estimation are substantial. Future work may involve optimizing the computational efficiency of these modules or extending the ACF principle to other families of invertible generative models.
Summary updated