Improving Variational Autoencoders with Inverse Autoregressive Flow

Diederik P. Kingma, Tim Salimans, Rafal Józefowicz, Xi Chen, Ilya Sutskever, Max Welling

Introduction

In the landscape of generative modeling, Variational Autoencoders (VAEs) have long been favored for their ease of training and rapid sampling capabilities. However, they traditionally rely on a "diagonal Gaussian" assumption for their approximate posterior, meaning they assume latent variables are entirely independent. This is a significant oversimplification; real-world data contains complex, non-linear dependencies that a simple Gaussian distribution cannot adequately capture, often resulting in blurry generated samples and lower overall likelihoods.

While "Normalizing Flows" were previously introduced to address this by transforming a simple distribution into a complex one through a series of invertible mappings, early iterations (such as planar or radial flows) struggled to scale to the high-dimensional latent spaces required for high-resolution images. This paper introduces Inverse Autoregressive Flow (IAF), a novel type of normalizing flow that allows VAEs to utilize highly complex and flexible latent distributions while remaining computationally efficient.

Comparison of prior and posterior distributions in standard VAEs versus VAEs with IAF.

The Inverse Autoregressive Flow (IAF) Method

The core innovation of this work is the IAF mechanism, which cleverly adapts autoregressive structures to achieve both high flexibility and parallelizable sampling.

  1. Autoregressive Foundation: The model builds upon the foundation of autoregressive models like MADE and PixelCNN, where each element of a generated vector depends sequentially on previously generated elements.
  2. The Inversion Trick: In standard autoregressive models, calculating the probability of a given data point is fast and parallelizable, but generating a new sample is a slow, sequential process. IAF flips this dynamic: it uses the autoregressive structure to create a transformation that is fast to sample. Because the "noise" used to generate the latent variables is already known during the inference step, the entire transformation can be computed in parallel across all dimensions.
  3. Chain of Transformations: IAF operates as a chain of these invertible transformations. To ensure the model captures a wide variety of dependencies across different dimensions, the authors reverse the ordering of the variables after each step in the flow chain.
  4. Numerical Stability: To maintain stable training dynamics, the authors employ a formulation inspired by LSTMs. Instead of relying on a raw linear transformation, they utilize a gating mechanism (similar to a "forget gate") to update the latent variables: $z_t = \sigma_t \odot z_{t-1} + (1 - \sigma_t) \odot m_t$.
Architecture of the approximate posterior using a chain of Inverse Autoregressive Flow (IAF) steps.

Key Insights

  • Parallelism is King: The primary breakthrough is the realization that while autoregressive models are typically slow to sample, structuring the flow appropriately allows the sampling process to become a single parallel pass. This makes IAF exceptionally well-suited for modern GPU acceleration.
  • Closing the Performance Gap: Historically, generative modeling faced a strict trade-off: VAEs were fast but yielded lower quality, whereas autoregressive models (like PixelCNN) offered high quality but were painfully slow. IAF effectively bridges this gap, granting VAEs the flexibility to match the likelihoods of autoregressive models without sacrificing their inherent speed.
  • Volume Preservation: By reversing the variable ordering between flow steps, the model successfully captures complex global dependencies without increasing the complexity of calculating the Jacobian determinant, which represents the computational "cost" of the transformation.

Datasets and Results

The authors evaluated IAF on two standard benchmarks: MNIST (binarized handwritten digits) and CIFAR-10 (32x32 color images).

  • Improved Likelihoods: On MNIST, IAF significantly improved the Variational Lower Bound (VLB). A VAE equipped with a depth-8 IAF achieved a log-likelihood of -79.10, outperforming standard VAEs and other contemporary flow-based models. On CIFAR-10, the model achieved 3.11 bits per dimension, establishing a state-of-the-art for variationally trained latent-variable models at the time and nearly matching the performance of the much slower PixelRNN (3.00 bits/dim).
  • Dramatic Synthesis Speedup: The most striking result is the sampling efficiency. On an NVIDIA Titan X GPU, IAF sampled images at a rate of 0.05 seconds per image. In stark contrast, PixelCNN required 52.0 seconds per image—representing a massive 1,000x speedup for the IAF-enhanced VAE.

Limitations and Future Work

While IAF represents a massive leap forward for VAEs, the authors noted a few limitations. First, pure autoregressive models (like Gated PixelCNN) still maintained a slight edge in raw log-likelihood at the time of publication. Second, the model is sensitive to initialization; it specifically requires a "forget gate bias" (keeping the gates mostly open at the start of training) to ensure effective learning. Finally, implementing IAF introduces architectural complexity, requiring a sophisticated setup of masked or convolutional autoregressive networks within the VAE framework.

Future directions suggested by the authors include adding deeper chains of flow steps or exploring alternative neural architectures for the autoregressive components to push performance even further.

Summary updated

BibTeX
@inproceedings{kingma2016improving,
  author = {Diederik P. Kingma and Tim Salimans and Rafal Józefowicz and Xi Chen and Ilya Sutskever and Max Welling},
  title = {{Improving Variational Autoencoders with Inverse Autoregressive Flow}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2016},
}
Figure