Source-linked AI summary

Variational Inference with Normalizing Flows

Danilo Jimenez Rezende, Shakir Mohamed

arXiv:1505.05770v6stat.MLcs.AIcs.LGstat.COstat.ME

TL;DR

Variational inference is limited by the choice of computationally feasible posterior approximation. This paper uses normalizing flows to construct flexible posteriors and reports clear improvements over simple approximations while retaining at-most-quadratic complexity.

  • Problem

    Variational inference needs richer, computationally feasible posterior approximations because limited approximations can underestimate uncertainty and impair predictions and decisions.

  • Method

    The paper constructs approximate posteriors by composing invertible transformations in normalizing flows within amortized variational inference.

  • Results

    The approach shows clear improvements over simple approximations across different problems, with overall algorithmic complexity at most quadratic.

  • Takeaways & Limitations

    Normalizing flows provide a unified spectrum of flexible posterior approximations whose asymptotic solution space can contain the true posterior.

  • Takeaways & Limitations

    The approach uses particular transformations, and designing alternatives for other posterior constraints while retaining efficient computation remains future work.

Abstract

from arXiv · show

The choice of approximate posterior distribution is one of the core problems in variational inference. Most applications of variational inference employ simple families of posterior approximations in order to allow for efficient inference, focusing on mean-field or other simple structured approximations. This restriction has a significant impact on the quality of inferences made using variational methods. We introduce a new approach for specifying flexible, arbitrarily complex and scalable approximate posterior distributions. Our approximations are distributions constructed through a normalizing flow, whereby a simple initial density is transformed into a more complex one by applying a sequence of invertible transformations until a desired level of complexity is attained. We use this view of normalizing flows to develop categories of finite and infinitesimal flows and provide a unified view of approaches for constructing rich posterior approximations. We demonstrate that the theoretical advantages of having posteriors that better match the true posterior, combined with the scalability of amortized variational approaches, provides a clear improvement in performance and applicability of variational inference.

1. Introduction

The paper addresses the limitation that variational inference often relies on restricted posterior approximations that cannot resemble true posteriors. It proposes normalizing flows as flexible, scalable transformations for constructing richer approximate posteriors.

  • Motivation: Variational inference is limited by approximate-posterior families, such as mean-field approximations, that may not resemble the true posterior.The paper identifies posterior approximation choice as a central limitation restricting variational methods’ power and adoption.
  • Motivation: Richer posterior approximations can improve performance, while limited approximations can have detrimental effects.The introduction cites autoregressive posterior dependencies as improving performance over mean-field approximations.
  • Related approaches: Mixture-model approximations offer flexibility but can limit scalability because each mixture component requires log-likelihood and gradient evaluation per update.This computational expense is described as typically costly for variational inference.
  • Contributions: The paper proposes normalizing flows, which construct complex approximate posteriors by transforming a density through a series of invertible mappings.The approach is presented as a new specification method for approximate posterior distributions in variational inference.
  • Contributions: Normalizing-flow inference provides a tighter, modified variational lower bound with additional terms having linear time complexity.The contribution is stated alongside the flow-based posterior construction.

2. Amortized Variational Inference

Amortized variational inference optimizes an evidence lower bound using scalable stochastic methods and represents approximate posteriors with inference networks. For continuous latent-variable models, stochastic backpropagation and deep latent Gaussian models provide an encoder-decoder implementation of this approach.

  • Variational inference replaces intractable marginalization with optimization of a lower bound on the marginal likelihood.The bound is also called the negative free energy or evidence lower bound (ELBO).
  • The ELBO combines a KL-divergence regularizer between approximate posterior and prior with a reconstruction-error term.It provides a unified objective for optimizing both model parameters θ and variational-approximation parameters φ.
  • Mini-batches and stochastic gradient descent scale variational inference, while remaining challenges are gradient estimation and selecting a rich, computationally feasible posterior.The expected log-likelihood gradient is ∇φEqφ(z)[log pθ(x|z)].
  • For continuous latent variables, stochastic backpropagation combines non-centered reparameterization with Monte Carlo approximation to compute variational gradients.The procedure reparameterizes latent variables from a known base distribution through a differentiable transformation, then backpropagates using Monte Carlo draws.
  • Inference networks amortize variational inference by learning an inverse map from observations to latent variables and replacing per-data-point variational parameters with global parameters.Their mean and standard-deviation functions can be specified using deep neural networks.
  • Deep latent Gaussian models are well suited to fast amortized inference and combine with inference networks as an encoder-decoder architecture known as a variational auto-encoder.DLGMs use continuous latent variables and are optimized with the lower bound and stochastic backpropagation.

3. Normalizing Flows

Normalizing flows construct flexible approximate posteriors by transforming simple densities through sequences of invertible mappings. Finite and infinitesimal flows provide a unified framework for obtaining increasingly complex distributions for variational inference.

  • Finite Flows: A normalizing flow transforms a probability density through a sequence of invertible mappings, applying the change-of-variables rule at each step.The resulting distribution remains a valid probability distribution.
  • Finite Flows: Composing several simple maps yields arbitrarily complex densities, with the transformed density determined by successive Jacobian adjustments.The construction transforms an initial variable z0 through K mappings fk to obtain qK.
  • Finite Flows: Normalizing flows let variational inference transform simple factorized distributions into increasingly complex and multi-modal approximate posteriors.The initial distribution can be an independent Gaussian, while flow length and transformation choices control complexity.
  • Infinitesimal Flows: As flow length tends to infinity, the transformation becomes an infinitesimal flow described by a partial differential equation governing density evolution over time.The continuous-time dynamics are represented as ∂qt(z)/∂t = Tt[qt(z)].
  • Infinitesimal Flows: Langevin flows evolve densities according to the Fokker–Planck equation, with the stationary solution determined by the model’s Boltzmann distribution.For an unnormalised log-density L(z), the stationary density is q∞(z) ∝ e−L(z).

4. Inference with Normalizing Flows

The section develops finite normalizing flows with tractable Jacobian computations, focusing on planar and radial transformations for flexible posterior construction. It integrates these flows into amortized variational inference while retaining at-most-quadratic algorithmic complexity.

  • Motivation: Finite-flow inference requires invertible transformations with efficient Jacobian-determinant computation because direct approaches can cost O(LD^3) and involve numerically unstable matrix inverses.The proposed flows therefore target low-cost determinant evaluation or avoid requiring the Jacobian altogether.
  • Finite flows: Planar flows apply contractions and expansions perpendicular to a hyperplane and compute the logdet-Jacobian in O(D) time.Their transformations use free parameters λ = {w, u, b} and a smooth element-wise nonlinearity h.
  • Finite flows: Radial flows apply contractions and expansions around a reference point while also permitting linear-time determinant computation.The transformation is parameterized by z0, α, and β, with r = |z − z0| and h(α, r) = 1/(α + r).
  • Finite flows: Not all planar or radial transformations are invertible, so the paper addresses invertibility conditions and numerically stable ways to satisfy them.These conditions are discussed in the appendix.
  • Amortized inference: The flow posterior is integrated into amortized variational inference by using an inference network to map observations x to the initial Gaussian density parameters.The resulting method forms one computational graph for gradients of both inference-network and generative-model parameters and uses stochastic gradient optimization.
  • Amortized inference: O(LN^2) + O(KD) is the joint sampling and log-det-Jacobian complexity, making the overall algorithm at most quadratic.Here L is the number of deterministic layers, N the average hidden-layer size, K the flow length, and D the latent dimension.

5. Alternative Flow-based Posteriors

This section unifies alternative flow-based posterior approximations by distinguishing general normalizing flows from volume-preserving flows according to Jacobian handling. It describes NICE as a finite volume-preserving flow and HVI as an infinitesimal volume-preserving flow, including mechanisms for component mixing and auxiliary variables.

  • Flow mechanisms: Flow mechanisms differ in Jacobian handling: general normalizing flows enable linear-time Jacobian computation, whereas volume-preserving flows enforce a Jacobian determinant of one.The paper’s method considers general normalizing flows; volume-preserving flows design transformations with unit Jacobian determinant.
  • NICE: NICE is a finite volume-preserving flow using neural-network transformations with easily computed inverses.Its transformations produce a Jacobian with a zero upper-triangular part and determinant 1.
  • NICE: NICE alternates partitionings of z into zA and zB to mix all components, with random permutation and random orthogonal transformation variants.The variants are called NICE-perm and NICE-orth.
  • HVI: HVI is an infinitesimal volume-preserving flow that introduces auxiliary variables ω alongside latent variables z.The approximation uses q(z, ω|x), assumes z and ω are independent initially, and applies a transformation f through the change-of-variables rule.

6. Results

The results evaluate normalizing-flow posterior approximations in deep latent Gaussian models using synthetic non-Gaussian densities and image datasets. Increasing flow length consistently improves approximation quality, variational bounds, and test likelihoods.

  • Experimental setup: Training uses stochastic backpropagation with a single latent-variable sample per data point per parameter update.Results are averaged over 100 random seeds after 500,000 parameter updates.
  • 2D density approximations: Normalizing flows substantially improve approximation quality for non-Gaussian 2D densities as the flow length increases from 2 to 8 and 32 transformations.The evaluated densities include multimodality and periodicity, which typical posterior approximations cannot capture.
  • MNIST: On MNIST, increasing flow length systematically improves the bound F and reduces the KL-divergence between q(z|x) and p(z|x).The comparison uses planar normalizing flows and NICE on the same deep latent Gaussian model.

7. Conclusion and Discussion

The paper presents normalizing flows as a scalable approach for learning highly non-Gaussian variational posteriors, combining flexible transformations with amortized inference and efficient Monte Carlo gradients. It concludes that flow complexity can be increased at runtime, while richer transformations and constraints remain important directions for future work.

  • Core contribution: Normalizing flows transform simple densities into highly non-Gaussian posterior approximations, improving over simple approximations when combined with amortized inference and efficient Monte Carlo gradient estimation.The approach was demonstrated across different problems.
  • Theoretical conclusion: In the asymptotic regime, some normalizing-flow classes are rich enough to contain the true posterior distribution.The discussion also connects this result with local convergence and consistency results for maximum likelihood estimation in certain latent-variable classes.
  • Complexity and future work: Posterior complexity can be controlled at runtime by increasing flow length, while alternative transformations can accommodate constraints such as restricted support.The paper identifies designing such alternative transforms as an important avenue for future research.

A. Invertibility conditions

This section describes the constraints required for invertible planar and radial normalizing-flow maps.

  • The section specifies invertibility constraints for the planar and radial normalizing flows introduced in Section 3.

A.1. Planar flows

Planar flows are not universally invertible, but with h(x)=tanh(x), invertibility is guaranteed by the sufficient condition w⊤u ≥ −1. This constraint can be enforced by modifying the component of u parallel to w.

  • Invertibility condition: With h(x)=tanh(x), a sufficient condition for planar-flow invertibility is w⊤u ≥ −1.The condition follows because 0 ≤ h′(α+b) ≤ 1 makes 1+w⊤u h′(α+b) ≥ 0 sufficient for monotonicity.
  • Inverse computation: Invertibility is established by decomposing z into components perpendicular and parallel to w, then solving uniquely for z⊥ and a scalar α.The scalar equation for α is obtained by taking the dot product of the inversion equation with w.
  • Constraint enforcement: The constraint is enforced by modifying u’s component parallel to w to produce ˆu satisfying w⊤ˆu > −1.The modification uses an arbitrary vector u and a compact correction involving a scalar function m(x)=−1+log(1+e^x).

A.2. Radial flows

Radial flows analyze invertibility by decomposing z into a center, radius, and direction, then solving separately for the direction and radius. A sufficient monotonicity condition is enforced through a reparameterization of β.

  • Radial flows: Invertibility of functions of the form (14) depends on the values of α and β.The analysis introduces the decomposition z = z0 + rˆz, with r = |z − z0|.
  • Radial flows: Given r and y = f(z), the transformed equation can be uniquely solved for the direction ˆz.Substituting the radial decomposition into the transformation yields equation (24).
  • Radial flows: The radius r is determined by subtracting equation (24) and taking norms, producing a scalar equation.This reduces inversion of the radial transformation to solving for the norm.
  • Radial flows: A sufficient invertibility condition is that the scalar equation’s right-hand side be non-decreasing in r.Because r ≥ 0, the condition is satisfied by imposing β ≥ −α.
  • Radial flows: The constraint β ≥ −α is enforced by reparameterizing β as ˆβ = −α + m(β), where m(x) = log(1 + e^x).The function m provides the stated parameterization used to impose the constraint.
Loading 1505.05770v6…