TL;DR
Variational inference replaces an impossible posterior with a simple guess and tunes the guess to fit. The usual guesses are independent Gaussians or mean-field families, and they cannot match the true posterior even with unlimited training. Rezende and Mohamed propose building the guess as a normalizing flow: start from a simple density and push samples through a sequence of invertible maps, keeping track of how each map stretches space so the final density is still exact. Their planar and radial flows are cheap to evaluate, and in deep latent Gaussian models the flows gave tighter bounds on the marginal likelihood than diagonal Gaussians or NICE-style flows.
Builds on: Normalizing Flow, Reparameterization Trick, Amortized Inference, Variational Lower Bound (ELBO) · Leads to: Variational Autoencoder
Why it mattered
Variational autoencoders became a default way to fit latent-variable generative models, and their encoders output a diagonal Gaussian. That choice is convenient, but it bounds how good the approximation can be. The paper gives a concrete fix that stays inside the same training loop: keep the Amortized Inference encoder and the Reparameterization Trick, then add a flow on top of the encoder's Gaussian sample. It is a concrete demonstration that a richer posterior can be made scalable, and it is the reference point for the question "how flexible must the posterior be?" in later Variational Autoencoder and Normalizing Flow work.
The paper also set out an organising idea. It groups finite flows, infinitesimal flows such as the Langevin and Hamiltonian flows from Markov chain Monte Carlo, and volume-preserving flows such as NICE, under one definition. That view made it easier to compare posterior approximations that had been developed separately.
History: before this paper, most variational methods used mean-field families. Structured mean-field and mixture approximations improved on them but were either still restricted or too expensive, as the introduction explains. The paper builds on earlier work by Tabak and Turner and by Tabak and Vanden-Eijnden on transforming densities for density estimation, and it cites NICE (Dinh et al., 2014) as the closest volume-preserving alternative. Its contribution was to put flows inside amortized variational inference with a cheap determinant, and to give a unified view of the approaches it drew on. It appeared as an arXiv preprint in 2015.
The problem
Suppose a model has observed data , hidden variables and parameters . The marginal likelihood is usually intractable, so the method maximises a lower bound on it. The bound uses an approximate posterior , and it is tight only when equals the true posterior .
Two problems have to be solved to make this work at scale. The first is computing gradients of the expected log-likelihood, which the paper handles with Monte Carlo estimates and reparameterisation. The second, which this paper addresses, is choosing a family for that is both rich enough and cheap to use. The paper's own argument is that the optimal would equal the true posterior, but independent Gaussians and mean-field families cannot represent the posterior's multiple modes, periodicity and correlations. Even when training is perfect, the bound stays loose. The paper cites evidence that limited posteriors cause under-estimated posterior variance and biased parameter estimates in time-series models.
Mixture posteriors are a natural alternative, but each extra component adds a full likelihood evaluation and gradient per update, which is expensive at scale. The paper needs a family whose density is computed in time that grows only linearly with the dimension.
How it works
Here is the method on one tiny one-dimensional example, step by step. The full model uses many layers and many flow steps, but each step works exactly like this.
- Start with a simple density. Let be a random number drawn from a standard Normal, . Its density at 1 is about 0.2420. We want a more flexible density than this one.
- Apply one invertible map. Use the planar map with , , . Then . Check: at the map returns , and at it returns . The map pushes points away from zero: positive points move right and negative points move left.
- Track how the map stretches space. The derivative is the local stretch factor. At it is , so the map has expanded that neighbourhood by about 42 percent. A stretch greater than one spreads the probability thinner there, so the density must drop.
- Update the density. The change-of-variables rule says the new density equals the old density divided by the stretch: . At the point , this gives . The density is lower because the map spread the mass.
- Repeat with more maps. Feed into a second map and multiply the stretch factors. After maps the log-density is the starting log-density minus the sum of the log stretch factors. This is the one bookkeeping rule the whole method depends on.
- Use the flow inside the bound. The approximate posterior is . The bound needs and . Expectations can be taken under the simple by sampling and pushing it through the maps, so the flow adds one extra term per map, which is cheap to compute for the planar family.
- f(x) = x + tanh(x)
- identity (no change)
flowchart LR A["z0 ~ q0 (simple Gaussian)"] --> B["f1: planar map"] B --> C["z1, density q1"] C --> D["f2: planar map"] D --> E["zK, density qK = approximate posterior"]
Worked examples
Use the one-dimensional planar map , so , , , and start at .
- Compute the image: .
- Compute the derivative . At , , so .
- Stretch factor: .
- Base density: .
- Flow density: .
Interpretation: the map doubles the length of the segment around zero, so the same probability is spread over twice the length and the density halves.
Use the same map and start at , with the density values from the walkthrough.
- Compute the image: .
- Compute , so .
- Stretch factor: .
- Base density: .
- Flow density at the image: .
- Check with logs: and , so , and .
Interpretation: the density at the new point is lower than the base density at the old point, because the map stretched the neighbourhood. The log form in step 6 is the one the bound actually uses.
The paper reports upper bounds on the negative log-probability of binarised MNIST test digits. Lower is better. The relevant entries are: diagonal Gaussian posterior ; planar flow with : ; : ; NICE with : ; NICE with : .
- Gain from the diagonal Gaussian to the planar flow at : .
- Gain from to for planar flows: .
- Gap between NICE and planar flows at : .
- Gap between NICE and planar flows at : .
- The planar-flow advantage over NICE is larger at the longer flow. The paper's explanation is that every planar parameter is learned, whereas NICE relies on a randomly initialised mixing step that is not learned.
Interpretation: a longer flow is better, and a learned planar map beats a fixed volume-preserving map at the same length. The comparison holds the model fixed, so the gaps are attributable to the posterior family.
Try it: using the planar-flow entries only, how much does the bound improve going from to ? Answer: . The gain is smaller than the gain from to (), so the returns diminish as the flow grows.
Common mistakes and tradeoffs
It is tempting to think that a normalizing flow is a generative model that replaces the encoder. In fact, in this paper the flow is a posterior approximation inside variational inference. It is trained through the same bound as the encoder, and it is used to approximate , not to model the data directly.
It is tempting to think that more flow steps always help. The paper shows steady gains up to on MNIST, but each step adds parameters and compute, and the gains get smaller. The right length depends on the budget.
It is tempting to think that the determinant has to be computed in full. In fact the planar and radial families are chosen so that the determinant reduces to one inner product or one scalar, which is why the method is scalable. A general invertible network would need the cost the paper warns about.
It is tempting to think that a volume-preserving flow is strictly worse. The NICE comparison shows that it can reach similar asymptotic quality when the flow is long, but it needs a random mixing step and more parameters. Its advantage is that its Jacobian determinant is exactly one, so no determinant has to be computed and the log-density correction is zero.
When to use this approach: the posterior is clearly non-Gaussian, you need an amortized encoder, and you can afford a few extra layers. When not to use it: the posterior is close to Gaussian and the extra flexibility would not change decisions, or the model is small enough that exact MCMC is cheaper. Alternatives include mixtures of Gaussians (which need one likelihood evaluation per component), structured mean-field families, and MCMC-style flows such as Langevin and Hamiltonian flows, which need likelihood gradients at each step.
The math
A normalizing flow is a sequence of invertible, differentiable maps applied to a random variable with density . Set . The resulting density satisfies .
Step 2 in symbols
The one-map case uses the change-of-variables rule , where . The paper's planar family is
where and are vectors in , is a scalar and is a smooth element-wise non-linearity, here . The walkthrough used , , , .
Step 3 in symbols
The stretch factor is the determinant of the Jacobian (see Jacobian Matrix and Determinant). For the planar map the matrix determinant lemma reduces it to a single number:
Here is the derivative of . In the walkthrough , so at the stretch is , as before. The cost is one inner product, so it is rather than the of a general Jacobian determinant.
Step 4 in symbols
For maps, the log-density is the sum of the log stretch factors:
Step 6 in symbols
Start from the bound, which the paper writes as with (see Variational Lower Bound (ELBO)). Substitute the flow density and change the expectation to the base distribution :
The first term is the entropy-like term of the base Gaussian, the second is the usual reconstruction term evaluated at the end of the flow, and the third is the new correction from the flow. The paper shows that the third term needs only the linear-time quantities above.
The paper's other map, the radial flow with and , also has a linear-time determinant. It expands or contracts space around a reference point instead of across a hyperplane.
The paper also gives a volume-preserving comparison family. The NICE map has Jacobian determinant exactly 1, so it contributes nothing to the log-density correction. Its inverse is easy to compute. The paper's result is that planar maps reach the same kind of flexibility with far fewer parameters, because all of their parameters are learned.
Invertibility needs a constraint. For planar maps with , a sufficient condition is , and the paper enforces it by adjusting along . The walkthrough satisfies it, since .
Results
The paper reports four kinds of evidence.
Representational power on 2D densities. The authors define four unnormalised 2D energy functions with multi-modality and periodicity, and approximate each with a flow of length 2, 8 or 32 starting from a diagonal Gaussian. Figure 3 shows that approximation quality improves as the flow length grows, and that the planar flow reaches the same asymptotic quality as NICE but with far fewer parameters. The paper states these comparisons qualitatively in the text.
MNIST, binarised. The model is a deep latent Gaussian model with 40 latent variables, trained for 500,000 updates. Table 2 gives the bounds quoted in the Worked examples above. The paper's own planar-flow entries are for , for , for and for . The table also lists results from other papers, including HVI with 1, 4 and 8 leapfrog steps (88.08, 86.40, 85.51) and DARN with 500 hidden units (84.71), which the authors attribute to different models and so are only indicative.
CIFAR-10 patches. The model uses 3 by 8 by 8 patches, 30 latent variables and a logit-normal observation model. Table 3 reports, under the heading , the values at , at , at and at . The paper's text says increasing systematically improves the test log-likelihood. The table does not explain its sign convention, so read the numbers with the paper's own description.
What the results do not show. Each comparison is a single model class with one optimiser setting (RMSprop, learning rate , momentum 0.9, mini-batches of 100), and the paper uses an annealed bound with an inverse temperature that rises from 0.01 to 1 over 10,000 iterations. The model comparisons against other papers use different architectures. The paper also notes that a Maxout non-linearity (a unit that takes the maximum over small groups of its inputs) was used in the deterministic layers. The results support the claim that a richer posterior helps in these experiments. They do not establish how much a flow helps on other tasks, and the paper does not claim that they do.
Reading guide
- Abstract and Section 1 (Introduction). Needs Variational Lower Bound (ELBO) and the idea of a posterior family. Read for the motivation: mean-field posteriors cannot match the true posterior.
- Section 2 (Amortized Variational Inference). Needs Amortized Inference, Reparameterization Trick and Stochastic Gradient Descent. Skip the MCCV discussion on first read.
- Section 2.3 (Deep Latent Gaussian Models). Needs Latent Variable Model and the idea of an encoder and decoder from Variational Autoencoder.
- Section 3 (Normalizing Flows). Needs Change of Variables Formula, Jacobian Matrix and Determinant. Equations (5) to (7) are the core of the method; work the walkthrough above alongside them.
- Section 3.2 (Infinitesimal Flows). Optional on first read. It needs the partial differential equation that describes how a density changes over time, and it names the Langevin and Hamiltonian flows as examples.
- Section 4 (Inference with Normalizing Flows). The planar and radial families, the flow-based bound, and the algorithm. Needs everything above.
- Section 5 (Alternative Flow-based Posteriors). Needs the volume-preserving idea. Read it for the comparison with NICE.
- Section 6 (Results) and the Appendix. Read the figure and table captions first, then the numbers. The appendix proves when the planar and radial maps are invertible; it uses only the calculus already introduced.
Recap
- A variational posterior is only as good as its family; Gaussian and mean-field families cannot match a multi-modal true posterior.
- A normalizing flow pushes a simple density through invertible maps and updates the density with the log stretch factor at each step (Change of Variables Formula).
- Planar and radial maps have determinants that cost , so a flow of length costs about times that.
- Inside the bound, the flow adds one log-determinant term to the usual reconstruction and prior terms, and training uses the reparameterised Monte Carlo gradient from Reparameterization Trick.
- In deep latent Gaussian models, longer planar flows gave steadily tighter bounds than diagonal Gaussians or NICE.
Read next: Variational Autoencoder for the model this paper plugs into, and Normalizing Flow for the broader family of flows and their uses in density estimation.
Check yourself
QuestionRecall: why is a mean-field Gaussian posterior limited even with perfect training?Show answer
Its family cannot represent the true posterior. Mean-field and independent Gaussian posteriors cannot capture multiple modes, periodicity or strong correlations, so the best member of the family stays a poor match. The bound is then loose however well the parameters are optimised.
QuestionCompute: for the planar map at , what is the flow density if ?Show answer
The stretch factor at zero is . Then , or about 0.1995.
QuestionWhy does the paper prefer a planar flow over a general invertible neural network as the flow?Show answer
A general invertible network has a Jacobian determinant that costs about to compute, and its gradients involve matrix inverses that can be numerically unstable. The planar map's determinant is a single inner product, so each step costs . That makes long flows affordable inside a training loop that runs hundreds of thousands of updates.
QuestionApplied: a researcher uses a planar flow of length 10 and sees the bound on a binarised MNIST-like task go from 89.9 (diagonal Gaussian) to 87.5. Using the paper's table, what would the length-80 planar flow be expected to give, and what is the total gain?Show answer
The paper's own length-80 planar bound is , so the expected result is about 85.1. The total gain from the diagonal Gaussian is , and the gain from length 10 to length 80 is . The researcher should expect a similar pattern on their own data, but the paper's numbers apply to its model and training setup, not to a different task.
Sources
- Rezende, D. J. and Mohamed, S. (2015). Variational Inference with Normalizing Flows. arXiv:1505.05770. https://arxiv.org/abs/1505.05770
- Kingma, D. P. and Welling, M. (2014). Auto-Encoding Variational Bayes. arXiv:1312.6114. https://arxiv.org/abs/1312.6114