Lecture 6 · Flow Models II: Coupling Layers, Dequantization and Continuous Flows

Deep Unsupervised Learning · Lecture 06。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: UC Berkeley CS294-158 Deep Unsupervised Learning (Spring 2024), Lecture 3 · Thu 2/1/2024 · Likelihood Models: Flow Models, second part (slides 42–66): change of many variables, composition, affine and elementwise flows, NICE / RealNVP coupling layers, the RealNVP architecture and its partitions, the choice of coupling transform (affine, mixture-of-logistics CDF, piecewise polynomials), “architecture matters” (Flow++), Glow (invertible 1×1 convolutions, interpolation, attribute control), continuous-time flows (FFJORD), flows on discrete data and dequantization, future directions. Also the variational-dequantization slides of Lecture 4 (slides 102–104). Basis: The slides give the constructions and show pictures of trained flows. These notes derive why coupling layers are invertible with triangular Jacobians, why uniform dequantization is a bound and how variational noise tightens it, and why continuous flows need only a trace. The experiments put every family on data with exact answers: 2-D densities with exact log-densities, Lecture 2’s discrete worlds with exact entropies, and binary ShapeWorld with its 17.80-bit floor — where flows can finally be compared, bit for bit, with the autoregressive models of Lectures 3–4. Code: code/lecture06/ (5 scripts + coupling.py; PyTorch (CPU); 10 s – 100 s each, except the image flows of script 04: ~15 minutes on the first run, then cached) Reading time: 4 hours including running the code


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. State the change-of-variables formula in many dimensions, explain ∣det⁡∣|\det| as a volume ratio, and explain why a general determinant (O(D3)O(D^3)) is unaffordable inside a training loop.
  2. Explain why affine flows are Gaussians and elementwise flows model only independent coordinates, and what composing them with linear mixing buys.
  3. Build an additive (NICE) and an affine (RealNVP) coupling layer, prove that it is invertible with a triangular Jacobian, and explain why its networks need no restrictions at all.
  4. Explain the RealNVP image architecture (checkerboard and channel masks, squeezing, multi-scale), why a bad partition hurts, and what Glow adds (ActNorm, invertible 1×1 convolutions) and Flow++ adds (mixture-CDF couplings, attention, variational dequantization).
  5. Derive the instantaneous change of variables of continuous-time flows and use Hutchinson’s trace estimator.
  6. Explain why a continuous density on discrete data can reach infinite likelihood, prove that uniform dequantization gives a lower bound on the discrete log-likelihood, and explain how variational dequantization tightens it.
  7. Read a flow’s bits per image as an upper bound and compare it honestly with exact autoregressive bits.

0.2 Prerequisites and scope

AssumedIntroduced hereDeveloped later
Lecture 5 (change of variables in 1-D/2-D, AF / IAF, triangular Jacobians)coupling layers, squeeze, ActNorm, 1×1 convolutions, multi-scale flowsVAEs with flow posteriors / IAF-VAE (Lecture 8)
Lecture 2 (discrete worlds with exact entropies, the density-at-center trap)dequantization (uniform, variational), the bound it givesdiffusion models as continuous-time models (Lectures 11–12)
Lectures 3–4 (exact bits on ShapeWorld: 22.3 / 18.8)continuous normalizing flows, Hutchinson’s estimatorflows as compressors, bits-back with dequantization (Lecture 21)

0.3 Map

§1  change of many variables: volumes, determinants and their cost                          ← code 01
§2  affine and elementwise flows                                                             ← code 01
§3  coupling layers: NICE, RealNVP, Flow++-style transforms; depth                          ← code 02
§4  flows for images: partitions, squeeze, Glow; flows on ShapeWorld                        ← code 04
§5  continuous-time flows                                                                    ← code 05
§6  discrete data: degeneracy, uniform and variational dequantization                       ← code 03, 04
§7  where flows stand
§8  summary   §9 pitfalls   §10 exercises   §11 further reading   §12 next lecture

0.4 Notation

SymbolMeaning
x∈RDx \in \mathbb{R}^D, z=f(x)z = f(x)data and latent, same dimension; ff invertible and differentiable
Jf(x)=∂f/∂xJ_f(x) = \partial f/\partial xthe D×DD \times D Jacobian; “logdet” =log⁡∣det⁡Jf∣= \log\lvert\det J_f\rvert
m∈{0,1}Dm \in \{0,1\}^Da coupling mask: 1 = kept (“conditioning”) variables, 0 = transformed
s(⋅),t(⋅)s(\cdot), t(\cdot)log-scale and shift networks of a coupling layer
v=x+uv = x + ua dequantized data point: integer xx plus noise u∈[0,1)Du \in [0,1)^D
q(u∣x)q(u \mid x)the dequantization noise distribution (uniform, or learned)
bits per image−log⁡2-\log_2 of a probability of a binary ShapeWorld image (an upper bound for flows)

0.5 How the experiments are run

2-D experiments reuse Lecture 5’s exact densities (two moons: truth 1.0245 nats on the test points; face 1.5640). The dequantization experiment uses homework 1 Q1’s two discrete worlds from Lecture 2 (exact entropies 3.454 and 5.293 bits). The image experiment uses Lecture 1’s 10,000 / 2,000 binary ShapeWorld images: every flow models v=x+u∈[0,2)288v = x + u \in [0, 2)^{288} after RealNVP’s logit preprocessing, and reports −Eq[log⁡2p(x+u)−log⁡2q(u∣x)]-E_q[\log_2 p(x + u) - \log_2 q(u \mid x)] — an upper bound on its discrete code length, comparable with the floor (17.80 bits), Lecture 3’s gated PixelCNN (22.28) and Lecture 4’s Transformer (18.79). The four image flows train for 3,000 steps of 64 images (~3–4 minutes each on a CPU) and are cached.


1. Change of many variables

1.1 Volumes

In 1-D, a flow stretches an interval dzdz into an interval dxdx and probability is conserved. In DD dimensions, the sampling map f−1f^{-1} turns a small cube dzdz into a small parallelepiped dxdx — to first order a linear map, given by the Jacobian. A linear map multiplies volumes by the absolute value of its determinant, so

pX(x) vol(dx)=pZ(z) vol(dz)⟹pX(x)=pZ(f(x)) ∣det⁡∂f(x)∂x∣.p_X(x)\,\mathrm{vol}(dx) = p_Z(z)\,\mathrm{vol}(dz) \quad\Longrightarrow\quad p_X(x) = p_Z(f(x))\,\Big\lvert \det \frac{\partial f(x)}{\partial x} \Big\rvert.

The slides’ intuition: xx is likely if it maps to a “large” region in zz space — a small neighbourhood of xx that the flow blows up into a big region of likely zz‘s. Script 01 checks both halves on a random 3-D flow and a hand-written 2-D “banana” flow (x1=z1x_1 = z_1, x2=z2e0.5sin⁡z1+0.5z12x_2 = z_2 e^{0.5\sin z_1} + 0.5 z_1^2):

z0z_0cube side δ\deltavol(dxdx) / vol(dzdz)∣det⁡∂x/∂z∣\lvert\det \partial x/\partial z\rvert
(+1.54, −0.29, −2.18)0.32.04772.1322
0.12.09532.1322
0.012.13402.1322
(+0.57, −1.08, −1.40)0.3 / 0.1 / 0.012.4787 / 2.5254 / 2.55122.5603

As the cube shrinks, the volume ratio converges to ∣det⁡∣|\det|. And for the banana, a histogram of 10610^6 samples (boxes of 0.05×0.050.05 \times 0.05) matches pZ(z) ∣det⁡∂z/∂x∣p_Z(z)\,|\det \partial z/\partial x| at six random points within 2–5% (sampling noise), while pZ(z)p_Z(z) alone is off by up to 60%.

1.2 The new key requirement

Training by maximum likelihood,

max⁡θ∑ilog⁡pZ(fθ(x(i)))+log⁡∣det⁡Jfθ(x(i))∣,\max_\theta \sum_i \log p_Z(f_\theta(x^{(i)})) + \log\big\lvert\det J_{f_\theta}(x^{(i)})\big\rvert,

needs the log-determinant for every training example at every step, and its gradient. A general determinant costs O(D3)O(D^3) (an LU decomposition). Script 01, Part 2:

DDgeneral matrix: slogdettriangular: ∑log⁡∣diag∣\sum \log\lvert\text{diag}\rvert
128~0.1 ms~0.03 ms
512~0.9 ms~0.01 ms
2048~8.6 ms~0.03 ms

For a 256×256256 \times 256 RGB image (D=196,608D = 196{,}608) a full determinant is ~101610^{16} operations per example — and that is before computing the Jacobian itself (DD backward passes). Hence the slides’ new key requirement: the Jacobian determinant must be easy to calculate and differentiate. Every practical flow is built from layers whose Jacobian is diagonal or triangular (determinant = product of the diagonal), or whose determinant has another cheap structure (LU-factored 1×11\times1 convolutions, §4.3).

1.3 Composition

Flows compose, x→f1→f2→⋯→fk→zx \to f_1 \to f_2 \to \dots \to f_k \to z, and by the chain rule det⁡Jfk∘⋯∘f1=∏jdet⁡Jfj\det J_{f_k \circ \dots \circ f_1} = \prod_j \det J_{f_j}: log-determinants add. Composition is “an easy way to increase expressiveness” (the slides) and the reason every architecture below is a stack of simple layers.


2. Affine and elementwise flows

2.1 Affine flows are Gaussians

The affine flow f(x)=A−1(x−b)f(x) = A^{-1}(x - b), i.e. sampling x=Az+bx = Az + b with z∼N(0,I)z \sim N(0, I), is another name for the multivariate Gaussian N(b,AA⊤)N(b, AA^\top). Its Jacobian is A−1A^{-1}, so the log-likelihood involves log⁡∣det⁡A∣\log|\det A| — expensive for large DD unless AA is kept triangular (a Cholesky factor). It is the baseline every flow must beat:

datafull-covariance Gaussiantruth
two moons (nats per point)1.90831.0245
ShapeWorld, dequantized (bits per image, upper bound)205.717.80

On ShapeWorld (script 01, Part 4), a uniform density on [0,2)288[0, 2)^{288} — knowing nothing — scores exactly 288.0 bits; a diagonal Gaussian is worse than that (294.9 bits: one smooth bump per pixel fits the two-box shape of a dequantized binary pixel, mass on [0,1)[0,1) or [1,2)[1,2), worse than a flat density does), and the full covariance reaches 205.7 — roughly Lecture 1’s independent Bernoulli pixels (212.1). Covariance captures “neighbouring pixels are both ink”, not shapes.

2.2 Elementwise flows

An elementwise flow transforms each coordinate by its own 1-D flow, zi=fi(xi)z_i = f_i(x_i): lots of freedom (any monotone map, Lecture 5), a diagonal Jacobian (cheap), but no interaction between coordinates — alone it can only model p(x1) p(x2)⋯p(x_1)\,p(x_2)\cdots. Interleaving elementwise flows with invertible linear maps lets each new elementwise layer act along new directions (an idea known as iterative Gaussianization). Script 01, Part 3 on two moons:

flowtest NLL− truth
Gaussian (affine flow)1.9083+0.884
elementwise only1.7849+0.760
elementwise → linear → elementwise1.4939+0.469
(elementwise → linear) × 4 → elementwise1.3981+0.374
(Lecture 5) AR flow, K=20K = 201.043–1.047+0.02

Composition helps, but slowly: an elementwise map cannot make the transform of x2x_2 depend on the value of x1x_1, which is exactly what bending two moons requires. Coupling layers provide that dependence.


3. Coupling layers

3.1 The construction

NICE (Dinh et al., 2014) and RealNVP (Dinh et al., 2017) split the variables in half, x=(xa,xb)x = (x_a, x_b), keep one half, and transform the other with an elementwise affine map whose parameters are computed from the kept half:

za=xa,zb=xb⊙exp⁡(sθ(xa))+tθ(xa).z_a = x_a, \qquad z_b = x_b \odot \exp\big(s_\theta(x_a)\big) + t_\theta(x_a).

Invertible, because the kept half passes unchanged and can recompute ss and tt:

xa=za,xb=(zb−tθ(za))⊙exp⁡(−sθ(za)).x_a = z_a, \qquad x_b = \big(z_b - t_\theta(z_a)\big) \odot \exp\big(-s_\theta(z_a)\big).

Tractable Jacobian, because it is triangular:

∂z∂x=(I0∂zb/∂xadiag(esθ(xa))),log⁡∣det⁡∣=∑jsθ(xa)j.\frac{\partial z}{\partial x} = \begin{pmatrix} I & 0 \\ \partial z_b/\partial x_a & \mathrm{diag}\big(e^{s_\theta(x_a)}\big) \end{pmatrix}, \qquad \log\lvert\det\rvert = \sum_j s_\theta(x_a)_j.

The lower-left block — however complicated — never enters the determinant. Hence the slides’ takeaway: coupling layers allow unrestricted neural nets sθ,tθs_\theta, t_\theta to be used in flows, while preserving invertibility and tractability. Think of them as data-parameterized elementwise flows. Both directions cost one pass: no sequential steps, unlike Lecture 5’s AF/IAF. One layer leaves half the variables untouched, so layers alternate which half is kept (in 2-D: keep x1x_1, then keep x2x_2, …). The code implements the split with a binary mask mm: z=m⊙x+(1−m)⊙(x⊙es(m⊙x)+t(m⊙x))z = m \odot x + (1 - m) \odot (x \odot e^{s(m \odot x)} + t(m \odot x)) (coupling.Coupling).

The additive coupling of NICE sets s=0s = 0: volume-preserving, log⁡∣det⁡∣=0\log|\det| = 0. NICE therefore ends with a diagonal scaling layer, the only place where volume can change.

3.2 The choice of coupling transform

“A Bayes net defines coupling dependency, but what invertible transformation ff to use is a design question” (the slides). Options:

  • affine (NICE, RealNVP, IAF-VAE, …) — closed-form inverse, the most common;
  • more complex, nonlinear monotone maps — “better performance”: CDFs / inverse CDFs of mixtures of Gaussians or logistics (Flow++), piecewise linear / quadratic functions (neural importance sampling), rational-quadratic splines (neural spline flows).

MixtureCDFCoupling2D implements a Flow++-style transform for 2-D: zb=logit(F(xb;θ(xa))) ea(xa)+b(xa)z_b = \mathrm{logit}\big(F(x_b; \theta(x_a))\big)\, e^{a(x_a)} + b(x_a) with FF an 8-component logistic-mixture CDF. Its inverse needs bisection (Lecture 5).

3.3 Experiments: depth is the price

Script 02 trains each flow for 6,000 Adam steps on the 2-D densities:

Two moons (truth 1.0245):

flowparamstest NLL− truthsamples in 99% region
NICE: additive × 8 + scaling36,9001.1102+0.08695.1%
RealNVP: affine × 836,8961.0622+0.03898.9%
Glow-style: (ActNorm, learned mixing, affine) × 837,0081.0645+0.04098.7%
Flow++-style: mixture-CDF × 423,9121.0866+0.06298.3%
(Lecture 5) AR flow, K=20K = 208,2481.0427–1.0469+0.02~98%

Face (truth 1.5640):

flowparamstest NLL− truthsamples in 99% region
RealNVP: affine × 418,4482.0667+0.50381.8%
RealNVP: affine × 836,8961.7896+0.22692.2%
RealNVP: affine × 1673,7921.6933+0.12995.2%
Flow++-style: mixture-CDF × 847,8241.7259+0.16294.7%
(Lecture 5) AR flow, K=20K = 208,2481.5876–1.5906+0.02~98%

Coupling flows on 2-D densities

Exact densities and coupling flows (02_coupling_layers_2d.py). Note the thin tears and folds: a smooth bijection from a Gaussian must stretch and cut its way to holes and rings.

  1. Additive couplings are weakest (their own Jacobian is 1; all stretching comes from the final scaling).
  2. Depth is the price of one-pass inversion. On the face, affine couplings improve from 4 → 8 → 16 layers (+0.50 → +0.23 → +0.13 nats) and are still far behind Lecture 5’s two-step AR flow. Half the variables pass each layer unchanged, and an affine map only shifts and stretches the other half; carving a ring with two eyes out of a Gaussian takes many such cuts.
  3. A more flexible transform helps per layer: 8 mixture-CDF couplings beat 8 affine ones (+0.16 vs +0.23).
  4. In 2-D, an AR flow is a coupling flow — two layers (an elementwise CDF of x1x_1; a CDF of x2x_2 given x1x_1) with the most flexible 1-D maps possible. Coupling layers do not win in 2-D; they win in many dimensions, where an AR flow needs DD sequential steps for one direction and a coupling flow a fixed number of layers for both.

Speed both ways (Part 3, 5,000 points of the face; timings vary between runs): an 8-layer RealNVP evaluates densities in ~3.5 ms and inverts in ~3 ms (closed form; round trip exact to 10−510^{-5}); the 8-layer mixture-CDF flow needs ~10 ms forward but ~480 ms to invert (bisection). Flexibility of the transform and speed of the inverse pull in opposite directions.


4. Flows for images

4.1 The RealNVP architecture and its partitions

For a 32×32×c32 \times 32 \times c image the slides list RealNVP’s multi-scale design: three checkerboard couplings, a channel squeeze, three channel couplings; split off half the variables as fine-grained latents z1z_1 (16×16×2c16 \times 16 \times 2c); repeat on the rest (z2z_2: 8×8×4c8 \times 8 \times 4c); finish with latents for the highest-level details (z3z_3: 4×4×16c4 \times 4 \times 16c).

  • A checkerboard mask keeps the pixels where row + column is even, so every transformed pixel is predicted from its four direct neighbours.
  • A squeeze reshapes each 2×22 \times 2 block into 4 channels: (C,H,W)→(4C,H/2,W/2)(C, H, W) \to (4C, H/2, W/2). It is a permutation (log-det 0), and after it a channel mask splits each 2×22\times2 block — pixels again conditioned on neighbours, now at a coarser scale.
  • Factoring out half the variables after each scale saves compute, and gives a hierarchy of latents.

Why partitions matter: the slides contrast a good partition (checkerboard × 4; squeeze; channel × 3; unsqueeze; checkerboard × 3) with a bad one (mask top half; bottom half; left half; right half, × 2) and show the bad one’s samples are worse. A transformed pixel can only be explained by the kept ones; with half-image masks, most pixels never see their own neighbours.

4.2 Glow and Flow++

Glow (Kingma & Dhariwal, 2018) replaces RealNVP’s fixed alternation by a learned step: ActNorm (a per-channel affine normalization initialized from the first batch so that activations have zero mean and unit variance, then trained like any parameter — unlike batch norm it is a fixed invertible map per example), an invertible 1×1 convolution (a learned C×CC \times C channel mixing, a generalization of “reverse the channels”), then an affine coupling. With the LU parameterization W=PL(U+diag(s))W = P L (U + \mathrm{diag}(s)), log⁡∣det⁡W∣=∑ilog⁡∣si∣\log|\det W| = \sum_i \log|s_i|: O(C)O(C) instead of O(C3)O(C^3) (times H⋅WH \cdot W positions). Glow trained at large scale and showed smooth interpolations between faces in latent space and attribute control (add the latent direction “smiling” to a face).

Flow++ (Ho et al., 2019) showed that “NN architecture also matters”: mixture-of-logistics CDF couplings + self-attention in the conditioner networks + variational dequantization (§6). The slides’ conclusion: the Bayes net (coupling dependency), the transformation class and the network architecture all play a role in a flow’s performance. (Reported results, CIFAR-10 test bits per dimension: RealNVP 3.49, Glow 3.35, Flow++ 3.08 — versus PixelCNN++ 2.92 for an autoregressive model.)

4.3 Flows on ShapeWorld

Script 04 trains four flows on binary ShapeWorld, all with the same budget: logit preprocessing, one squeeze to 4×6×124 \times 6 \times 12, then 10 affine couplings with identical conditioner CNNs (32 channels, 3 layers); they differ only in the partition or the step:

modelparamstest bits per image (2,000 images)
RealNVP partitions (checkerboard + channel, alternating)130,320132.9
bad partition (top / bottom / left / right halves)130,320154.5
Glow steps (ActNorm + 1×1 conv + coupling)130,760123.2
Glow steps + variational dequantization130,76094.7
(script 01) full-covariance Gaussian–205.7
(Lecture 3) gated PixelCNN, exact–22.28
(Lecture 4) Transformer on 2×2 patches, exact–18.79
exact entropy–17.80

(training curves, test bits at steps 600 / 1200 / 1800 / 2400 / 3000: RealNVP 152 / 142 / 137 / 134 / 133; bad partition 169 / 161 / 158 / 155 / 155; Glow 146 / 135 / 128 / 125 / 124; Glow + VD 114 / 104 / 100 / 97 / 96.)

The numbers deliver the slides’ caveat — “performance not as good as other models” — in its starkest form:

  1. Flows are 5× further from the floor than our worst autoregressive model. A smooth bijection must turn the 921,600 sharp-edged unit cubes of dequantized ShapeWorld (one per possible image, each with a flat density inside) into one Gaussian blob. Binary data are the hardest case for flows; on 8-bit photos, where neighbouring intensities vary smoothly, the reported gap is 0.15–0.6 bits per dimension (the CIFAR-10 numbers of §4.2).
  2. The partition matters: the bad partition costs 22 bits, with the same layers and parameters.
  3. Learned mixing helps: Glow’s steps beat fixed alternation by 10 bits.
  4. Variational dequantization is the largest single gain: 28 bits with the same flow (§6).

(Plan vs reality: a first prototype kept the first couplings at full 12×2412 \times 24 resolution; it reached ~125 bits after 1,500 steps but cost 0.15 s per step. All four flows now work at 4×6×124 \times 6 \times 12 after one squeeze — fair, and ~3× cheaper.)

Samples, temperature, interpolation. No sample of any of the four flows — at temperature T=1T = 1, 0.70.7 or 0.50.5 (Glow’s trick of sampling z∼N(0,T2I)z \sim N(0, T^2 I)) — is a valid ShapeWorld image; the nearest valid image is 24–53 pixel flips away (Lecture 3’s gated PixelCNN: 38% valid). Lowering the temperature does not help here: near z=0z = 0, the Glow flow decodes to ink-filled blobs (89% ink at T=0.5T = 0.5, against 26% in real images). Interpolating linearly between the latents of two test images (Glow’s interpolation slides) reproduces both end points exactly but passes through broken, overlapping shapes: 2 of 8 frames valid — the two ends.

Flow samples

Samples at temperature 0.7 of the four flows (04_flows_on_shapeworld.py).


5. Continuous-time flows

5.1 From many small steps to an ODE

Take a residual flow layer x↦x+h g(x)x \mapsto x + h\,g(x) with small hh. Its Jacobian is I+hJgI + h J_g, and log⁡det⁡(I+hJg)=h tr(Jg)+O(h2)\log\det(I + hJ_g) = h\,\mathrm{tr}(J_g) + O(h^2). Chaining infinitely many infinitesimal steps gives an ODE dx/dt=g(x,t)dx/dt = g(x, t) and the instantaneous change of variables (Chen et al., 2018):

dlog⁡p(x(t))dt=− tr(∂g∂x(x(t),t)),log⁡pdata(x)=log⁡pZ(z)+∫01tr(∂g∂x) dt.\frac{d \log p(x(t))}{dt} = -\,\mathrm{tr}\Big(\frac{\partial g}{\partial x}(x(t), t)\Big), \qquad \log p_{\text{data}}(x) = \log p_Z(z) + \int_0^1 \mathrm{tr}\Big(\frac{\partial g}{\partial x}\Big)\,dt.

Three consequences, which are the slides’ “allows for unrestricted architectures; invertibility and fast log-probability computation guaranteed”:

  • Any network gg works: an ODE with a Lipschitz velocity field is invertible by running it backwards.
  • Only the trace is needed, not the determinant.
  • FFJORD (Grathwohl et al., 2018) estimates the trace without forming the Jacobian: tr(A)=E[ε⊤Aε]\mathrm{tr}(A) = E[\varepsilon^\top A \varepsilon] for any probe with E[εε⊤]=IE[\varepsilon\varepsilon^\top] = I, and ε⊤Jg\varepsilon^\top J_g is one vector-Jacobian product — one backward pass, whatever DD.

5.2 Experiments

Script 05, Part 1 (a random MLP g:RD→RDg: \mathbb{R}^D \to \mathbb{R}^D, 2,000 probes):

DDexact traceRademacher probe: mean ± stdGaussian probe: mean ± std
2−0.0807−0.0810 ± 0.015−0.0784 ± 0.294
16+0.1809+0.1852 ± 0.901+0.1695 ± 1.016
128+0.0356+0.0462 ± 2.964+0.0923 ± 2.918

The estimator is unbiased; its noise grows with DD. Rademacher (±1) probes remove the diagonal’s contribution to the variance (Exercise 10): far less noise when the diagonal dominates (D=2D = 2), about the same when off-diagonal terms dominate.

Part 2 trains a small CNF (velocity MLP with 4,546 parameters, RK4 with 8 steps, 2,500 Adam steps) on two moons:

modelparamstest NLL− truthsamples in 99% regiontrain time
CNF, exact trace4,5461.0707+0.04696.7%~35 s
CNF, Hutchinson trace4,5461.0727+0.04896.4%~25 s
RealNVP: affine × 836,8961.0622+0.03898.9%~9 s
AR flow, K=20K = 208,2481.0427+0.01898.4%~3 s

CNF

The ODE carries the data (left) to a Gaussian (third panel); samples run it backwards (05_continuous_flows.py).

A CNF with an eighth of RealNVP’s parameters is nearly as good; training with the noisy trace costs 0.002 nats. Part 3 shows what “guaranteed” means:

RK4 stepstest NLL (2,000 points)max round-trip errornetwork calls per direction
21.04932.1e-018
41.05902.4e-0216
81.06094.7e-0432
161.06111.9e-0564
321.06116.4e-07128

Invertibility and the log-density are exact up to the ODE solver. With 2 steps the round trip is off by 0.2 and the reported NLL even looks 0.012 nats better — not a better model, a number that is no longer an exact log-density. A CNF trades the coupling layer’s architectural constraint for solver cost, in both directions. (Lectures 11–12 meet ODEs again: diffusion models’ probability-flow ODEs and flow matching train the same kind of velocity field without simulating it during training.)


6. Flows on discrete data: dequantization

6.1 The degeneracy

Images are discrete (binary ShapeWorld pixels; 8-bit photos). A continuous density fitted directly to discrete values has an easy way to win: put infinitely tall, infinitely thin spikes on the data values. “What density does a model assign to values between bins like 0.4, 0.42…?” (the slides) — none, and the likelihood goes to infinity. Script 03 (homework 1 Q1’s world 1: values 0..19, H=3.4543H = 3.4543 bits) shows it two ways:

logistic bumps on the integers, scale ss−log⁡2p(x)-\log_2 p(x) at the data (“bits”)−log⁡2P(unit cell around x)-\log_2 P(\text{unit cell around } x)
1+3.7253.7286
0.1+2.1223.4466
0.01−1.2003.4443
0.001−4.5223.4443

Every factor of 10 in the scale buys log⁡210=3.3\log_2 10 = 3.3 “bits”, while the probability of each unit cell — the real discrete probability — does not change. And maximum likelihood finds the spikes: a 20-component mixture trained on the raw integers reports −0.13, −3.56, −3.12, … “bits” on the test set, below the entropy and below zero, which no discrete model can do. These numbers are meaningless — Lecture 2’s “density at the center” trap, now with a flexible model.

6.2 Uniform dequantization is a bound

The fix (Theis, van den Oord & Bethge, 2016): add noise. Train the continuous density on v=x+uv = x + u with u∼U[0,1)Du \sim U[0,1)^D. Each discrete value xx owns the unit cube x+[0,1)Dx + [0,1)^D, and the model’s discrete probability is the mass of that cube:

P(x):=∫[0,1)Dp(x+u) du.P(x) := \int_{[0,1)^D} p(x + u)\,du.

By Jensen’s inequality (log⁡\log is concave),

log⁡P(x)=log⁡Eu∼U[p(x+u)]  ≥  Eu∼U[log⁡p(x+u)].\log P(x) = \log E_{u \sim U}[p(x + u)] \;\ge\; E_{u \sim U}[\log p(x + u)].

So the dequantized objective is a lower bound on the discrete log-likelihood: the reported bits are an upper bound on a code length, and the model cannot cheat by spiking — a spike would make pp tiny on most of the cube. The bound is tight exactly when pp is constant on each cube. (The slides’ semantics: “we want the integral of probability density within a discrete interval to approximate discrete probability mass.”)

6.3 Variational dequantization

Flow++ makes the noise learnable: draw u∼q(u∣x)u \sim q(u \mid x) and use importance sampling,

log⁡P(x)=log⁡Eu∼q[p(x+u)q(u∣x)]  ≥  Eu∼q[log⁡p(x+u)−log⁡q(u∣x)].\log P(x) = \log E_{u \sim q}\Big[\frac{p(x + u)}{q(u \mid x)}\Big] \;\ge\; E_{u \sim q}\big[\log p(x + u) - \log q(u \mid x)\big].

Uniform qq is the special case log⁡q=0\log q = 0. A learned qq can follow the shape of pp inside each cube, so the model no longer has to be flat there — the same ELBO structure as the VAE of Lecture 7, with uu as the latent variable. Script 03, Part 3 (a Beta noise distribution per value, whose family contains the uniform):

worldmixturenoisebound (bits)same model, exact discreteJensen gapbound − truth
1 (HH = 3.454)K=10K = 10uniform3.49523.47030.0249+0.052
K=10K = 10variational3.45373.44650.0072+0.010
K=20K = 20uniform3.46763.45560.0120+0.024
K=20K = 20variational3.44793.44490.0030+0.005
2 (HH = 5.293)K=10K = 10uniform5.31055.30560.0049+0.008
K=10K = 10variational5.30575.30550.0002+0.003

(For a 1-D mixture-CDF flow the exact cell mass F(x+1)−F(x)F(x+1) - F(x) is computable, which lets us see the Jensen gap directly.) Variational noise shrinks the gap 3.5–25×, and the bound moves close to the truth. The gain is largest in world 1, where the true mass piles up in value 0 and the density varies inside the cells.

Dequantization

Left: no dequantization — the density spikes on the integers (log scale). Middle: uniform dequantization. Right: learned noise distributions q(u∣x)q(u \mid x), far from uniform for x=0,1x = 0, 1 (03_dequantization.py).

On ShapeWorld (§4.3) variational dequantization is worth 28 bits with the same flow. And the bound itself is loose: script 04, Part 2 importance-samples the noise, log⁡1K∑kp(x+uk)/q(uk∣x)\log \frac1K \sum_k p(x + u_k)/q(u_k \mid x), which tightens as KK grows (the IWAE bound of Lecture 7):

modelK=1K = 1 (the usual bound)K=16K = 16K=256K = 256
Glow steps, uniform noise124.8110.7105.8
Glow steps, variational noise97.488.183.8

(200 test images.) At least 14–19 bits of the reported numbers are looseness of the bound, not the flow — and even K=256K = 256 is still a bound. When flows are compared with discrete models, the dequantization bound is part of what is being compared.


7. Where flows stand

The slides close with the ultimate goal — a likelihood-based model with fast sampling, fast inference, fast training, good samples and good compression — and note that flows achieve some of these criteria, but “how exactly do we design and compose flows for great performance? That’s an open question”, with requirements that may pose permanent challenges:

  • dimensionality preserving: zz has as many numbers as xx — no compression into a small latent (the VAE’s strength, Lectures 7–8);
  • invertibility: every layer must be a bijection, which constrains architectures (or, for CNFs, costs solver steps);
  • cheap determinant: triangular structure, hence depth.

The scoreboard on ShapeWorld after six lectures (bits per image; floor 17.80):

model familybest resultsamplinglatent
autoregressive Transformer, 2×2 tokens (L4)18.79 (exact)72 sequential stepsnone
gated PixelCNN (L3)22.28 (exact)288 sequential stepsnone
Glow steps + variational dequantization (L6)94.7 (bound)one pass288-D, invertible
full-covariance Gaussian (L6)205.7 (bound)one pass288-D

Flows deliver the promised one-pass sampling and an exact latent space, and they remain important as building blocks — posteriors in VAEs (IAF-VAE), dequantizers, compressors (Lecture 21), and the conceptual ancestors of continuous-time diffusion and flow-matching models (Lectures 11–12). As density models of discrete images they are behind.


8. Summary

  1. In DD dimensions pX(x)=pZ(f(x)) ∣det⁡∂f/∂x∣p_X(x) = p_Z(f(x))\,|\det \partial f/\partial x|: a volume ratio. Training needs the log-determinant for every example, so flows use layers with diagonal or triangular Jacobians; log-determinants add under composition.
  2. Affine flows are Gaussians (two moons: +0.88 nats; ShapeWorld: 205.7 bits). Elementwise flows model independent coordinates; interleaving them with linear mixing helps slowly.
  3. Coupling layers keep half the variables and transform the other half elementwise with parameters from any network of the kept half: triangular Jacobian, log⁡∣det⁡∣=∑s\log|\det| = \sum s, one-pass inverse. They need depth (16 affine layers on the face are still 0.13 nats off where a 2-step AR flow is 0.02 off); more flexible transforms (mixture CDFs, splines) help per layer but may need numerical inverses.
  4. For images, partitions (checkerboard, squeeze + channel) matter (a bad partition cost 22 bits); Glow adds ActNorm and LU-parameterized 1×1 convolutions (−10 bits); Flow++ adds mixture-CDF couplings, attention and variational dequantization.
  5. Continuous flows need only a trace (−∫tr ∂g/∂x dt-\int \mathrm{tr}\,\partial g/\partial x\,dt), estimated with one Hutchinson probe; any network works, exactness holds up to the solver.
  6. Continuous densities on discrete data can spike to infinite likelihood. Uniform dequantization turns the flow’s likelihood into a lower bound on the discrete one; variational dequantization tightens it (3.5–25× smaller Jensen gaps in 1-D; −28 bits on ShapeWorld).
  7. On binary ShapeWorld, flows reach 95–155 bits (bounds) where autoregressive models reach 18.8–22.3 exact bits, and no flow sample is valid: one-pass sampling and an exact latent space have not bought sample quality here.

9. Common pitfalls

  1. Reporting flow likelihoods on discrete data without dequantization. Negative “bits” or values below the entropy are the spike degeneracy, not a good model (§6.1).
  2. Comparing a dequantized bound with an exact likelihood as if both were exact. The flow’s number is an upper bound; at least 14–19 bits of it were looseness on ShapeWorld (§6.3).
  3. Forgetting the preprocessing’s log-determinant. Scaling to [0,1][0,1], the logit transform, and squeezing all change (or, for squeeze, preserve) volume; only the complete map from vv to zz gives a density of vv.
  4. Couplings that never transform some variables. Masks must alternate (or be mixed by 1×1 convolutions); a variable kept in every layer is modelled by the base distribution alone.
  5. A bad partition. Masks should let each transformed variable see its neighbours (checkerboard, squeeze + channel).
  6. ActNorm without data-dependent initialization, or used like batch norm (different statistics per batch): the map must be fixed for each example to be a flow.
  7. Trusting a CNF’s density with too few solver steps. Check the round trip and the stability of the NLL as steps increase.
  8. Expecting temperature to fix samples. Reduced temperature helps when the latent’s centre decodes to typical data; here it decoded to ink-filled blobs.

10. Exercises

Exercise 1 (change of many variables). Starting from P(X∈A)=P(Z∈f(A))P(X \in A) = P(Z \in f(A)) for any small region AA, derive pX(x)=pZ(f(x))∣det⁡Jf(x)∣p_X(x) = p_Z(f(x))|\det J_f(x)|. Show that for f=f2∘f1f = f_2 \circ f_1, log⁡∣det⁡Jf(x)∣=log⁡∣det⁡Jf1(x)∣+log⁡∣det⁡Jf2(f1(x))∣\log|\det J_f(x)| = \log|\det J_{f_1}(x)| + \log|\det J_{f_2}(f_1(x))|.

Answer

P(Z∈f(A))=∫f(A)pZ(z) dz=∫ApZ(f(x)) ∣det⁡Jf(x)∣ dxP(Z \in f(A)) = \int_{f(A)} p_Z(z)\,dz = \int_A p_Z(f(x))\,|\det J_f(x)|\,dx by the substitution rule for multiple integrals. Since this equals ∫ApX(x) dx\int_A p_X(x)\,dx for every small AA, the integrands agree. For the composition, Jf(x)=Jf2(f1(x)) Jf1(x)J_f(x) = J_{f_2}(f_1(x))\,J_{f_1}(x) (chain rule), and det⁡(AB)=det⁡Adet⁡B\det(AB) = \det A \det B.

Exercise 2 (the coupling layer). For za=xaz_a = x_a, zb=xb⊙es(xa)+t(xa)z_b = x_b \odot e^{s(x_a)} + t(x_a), write the inverse, the Jacobian, and its log-determinant. Why may ss and tt be arbitrary networks, while the map xb↦zbx_b \mapsto z_b must be elementwise and monotone?

Answer

Inverse: xa=zax_a = z_a, xb=(zb−t(za))⊙e−s(za)x_b = (z_b - t(z_a)) \odot e^{-s(z_a)}. Jacobian: (I0∗diag(es(xa)))\begin{pmatrix} I & 0 \\ \ast & \mathrm{diag}(e^{s(x_a)}) \end{pmatrix}, log-det =∑jsj(xa)= \sum_j s_j(x_a). ss and tt are only ever evaluated (on the kept half, which is available in both directions), never inverted, so they can be anything. The map on xbx_b must be invertible for each fixed xax_a with a cheap determinant: elementwise affine with a positive scale is, and so is any elementwise monotone map (mixture CDF, spline).

Exercise 3 (NICE). Show that an additive coupling (s=0s = 0) has det⁡=1\det = 1. Why can a stack of additive couplings never fit a narrow Gaussian N(0,0.012I)N(0, 0.01^2 I) starting from N(0,I)N(0, I), and what does NICE add to fix it?

Answer

With s=0s = 0 the Jacobian is unit lower-triangular: determinant 1, volume preserved. A volume-preserving map from N(0,I)N(0, I) can move and shear mass but never concentrate it: the image of a unit-volume region has unit volume, so the density can never exceed the base’s maximum (2π)−D/2(2\pi)^{-D/2}, while N(0,0.012I)N(0, 0.01^2 I) needs a density 102D10^{2D} times higher. NICE ends with a diagonal scaling layer z=eλ⊙xz = e^{\lambda} \odot x, contributing ∑jλj\sum_j \lambda_j to the log-det.

Exercise 4 (affine flow MLE). For the flow x=Az+bx = Az + b, z∼N(0,I)z \sim N(0, I), show that the maximum-likelihood bb is the sample mean and AA⊤AA^\top the sample covariance. What does each likelihood evaluation cost if AA is a general matrix, and if it is lower triangular?

Answer

The model is N(b,Σ)N(b, \Sigma) with Σ=AA⊤\Sigma = AA^\top; the Gaussian MLE gives b^=xˉ\hat b = \bar x, Σ^=1n∑(xi−xˉ)(xi−xˉ)⊤\hat\Sigma = \frac1n \sum (x_i - \bar x)(x_i - \bar x)^\top (any AA with AA⊤=Σ^AA^\top = \hat\Sigma is optimal: the flow is not identifiable). With general AA: solving Az=x−bAz = x - b and log⁡∣det⁡A∣\log|\det A| cost O(D3)O(D^3) (once per parameter update, then O(D2)O(D^2) per example). With triangular AA: back substitution O(D2)O(D^2) and log⁡∣det⁡A∣=∑log⁡∣Aii∣\log|\det A| = \sum \log|A_{ii}|, O(D)O(D).

Exercise 5 (squeeze and 1×1 convolutions). Show that the squeeze operation has ∣det⁡∣=1|\det| = 1. For Glow’s W=PL(U+diag(s))W = PL(U + \mathrm{diag}(s)) applied at every pixel of an H×WH \times W image with CC channels, show log⁡∣det⁡∣=HW∑ilog⁡∣si∣\log|\det| = H W \sum_i \log|s_i| and compare the cost with computing det⁡W\det W directly.

Answer

Squeeze permutes the entries of the tensor: its Jacobian is a permutation matrix, determinant ±1. For the 1×1 convolution, the full Jacobian is block-diagonal with HWHW copies of WW, so log⁡∣det⁡∣=HWlog⁡∣det⁡W∣\log|\det| = HW \log|\det W|. det⁡P=±1\det P = \pm1, det⁡L=1\det L = 1 (unit triangular), det⁡(U+diag(s))=∏si\det(U + \mathrm{diag}(s)) = \prod s_i (triangular): log⁡∣det⁡W∣=∑log⁡∣si∣\log|\det W| = \sum\log|s_i|, O(C)O(C), versus O(C3)O(C^3) for a direct determinant — and its gradient is trivial.

Exercise 6 (ActNorm vs batch norm). Why is batch normalization (with batch statistics) not a flow layer, while ActNorm is? What is ActNorm’s log-determinant on a C×H×WC \times H \times W input?

Answer

With batch statistics, the output for one example depends on the other examples in the batch: the map from one xx to its zz is not a fixed function, so p(x)p(x) is ill-defined (at test time with running statistics it is a fixed affine map, which is a flow — but then train and test models differ). ActNorm uses parameters (initialized from one batch, then learned) — a fixed per-channel affine map: log⁡∣det⁡∣=HW∑clog⁡∣1/σc∣\log|\det| = HW \sum_c \log|1/\sigma_c| for z=(x−b)/σz = (x - b)/\sigma.

Exercise 7 (the dequantization bound). Prove Eu∼U[0,1)D[log⁡p(x+u)]≤log⁡∫[0,1)Dp(x+u) duE_{u \sim U[0,1)^D}[\log p(x + u)] \le \log \int_{[0,1)^D} p(x + u)\,du and that equality holds iff pp is constant (a.e.) on the cube. Then show the variational version Eq[log⁡p(x+u)−log⁡q(u∣x)]≤log⁡P(x)E_{q}[\log p(x+u) - \log q(u\mid x)] \le \log P(x) with equality iff q(u∣x)=p(x+u)/P(x)q(u \mid x) = p(x + u)/P(x).

Answer

Jensen: E[log⁡Y]≤log⁡E[Y]E[\log Y] \le \log E[Y] for Y=p(x+u)>0Y = p(x + u) > 0, with equality iff YY is a.s. constant. Variational: log⁡P(x)=log⁡Eq[p(x+u)/q(u∣x)]≥Eq[log⁡(p(x+u)/q(u∣x))]\log P(x) = \log E_q[p(x+u)/q(u\mid x)] \ge E_q[\log (p(x+u)/q(u \mid x))], with equality iff the ratio is constant, i.e. q(u∣x)∝p(x+u)q(u \mid x) \propto p(x + u) on the cube: qq = the model’s own conditional density on the cell. The gap is KL(q(u∣x) ∥ p(x+u)/P(x))\mathrm{KL}(q(u\mid x) \,\Vert\, p(x+u)/P(x)) — the same identity as the ELBO gap of Lecture 7.

Exercise 8 (spikes). A logistic bump of scale ss centred on an integer kk with weight πk\pi_k has density πk/(4s)\pi_k/(4s) at kk. Show that −log⁡2-\log_2 of the density at the data decreases by log⁡210≈3.32\log_2 10 \approx 3.32 bits per factor 10 in ss, and that the unit-cell mass converges to πk\pi_k.

Answer

The logistic density at its centre is 1/(4s)1/(4s), so −log⁡2(πk/(4s))=−log⁡2πk+log⁡24s-\log_2(\pi_k/(4s)) = -\log_2 \pi_k + \log_2 4s: dividing ss by 10 subtracts log⁡210\log_2 10. The cell mass πk[σ(12s)−σ(−12s)]→πk\pi_k[\sigma(\tfrac{1}{2s}) - \sigma(-\tfrac{1}{2s})] \to \pi_k as s→0s \to 0 (plus vanishing contributions from other bumps): the discrete probabilities converge to the training frequencies, while the “density bits” diverge to −∞-\infty (script 03, Part 1).

Exercise 9 (instantaneous change of variables). Derive ddtlog⁡p(x(t))=−tr ∂g/∂x\frac{d}{dt}\log p(x(t)) = -\mathrm{tr}\,\partial g/\partial x from the Euler step xt+h=xt+h g(xt,t)x_{t+h} = x_t + h\,g(x_t, t).

Answer

log⁡pt+h(xt+h)=log⁡pt(xt)−log⁡∣det⁡(I+hJg)∣\log p_{t+h}(x_{t+h}) = \log p_t(x_t) - \log|\det(I + h J_g)|. For small hh, det⁡(I+hJ)=1+h tr(J)+O(h2)\det(I + hJ) = 1 + h\,\mathrm{tr}(J) + O(h^2), so log⁡det⁡(I+hJ)=h tr(J)+O(h2)\log\det(I + hJ) = h\,\mathrm{tr}(J) + O(h^2). Dividing by hh and letting h→0h \to 0: ddtlog⁡p(x(t))=−tr(Jg)\frac{d}{dt}\log p(x(t)) = -\mathrm{tr}(J_g).

Exercise 10 (Hutchinson’s variance). For a matrix AA and a probe ε\varepsilon with independent components, mean 0, variance 1, show E[ε⊤Aε]=trAE[\varepsilon^\top A\varepsilon] = \mathrm{tr}A. Show that for Gaussian probes Var=∥A∥F2+tr(A2)\mathrm{Var} = \lVert A \rVert_F^2 + \mathrm{tr}(A^2) (i.e. 2∥Asym∥F22\lVert A_{\text{sym}}\rVert_F^2), and for Rademacher probes the diagonal’s contribution 2∑iAii22\sum_i A_{ii}^2 disappears.

Answer

E[∑ijεiAijεj]=∑ijAijδij=trAE[\sum_{ij}\varepsilon_i A_{ij}\varepsilon_j] = \sum_{ij} A_{ij}\delta_{ij} = \mathrm{tr}A. Write B=AsymB = A_{\text{sym}}; ε⊤Aε=ε⊤Bε=∑iBiiεi2+2∑i<jBijεiεj\varepsilon^\top A\varepsilon = \varepsilon^\top B\varepsilon = \sum_i B_{ii}\varepsilon_i^2 + 2\sum_{i<j}B_{ij}\varepsilon_i\varepsilon_j. The cross terms have variance 4∑i<jBij2=2∑i≠jBij24\sum_{i<j}B_{ij}^2 = 2\sum_{i \ne j}B_{ij}^2 for both probes; the diagonal terms have variance ∑iBii2 Var(εi2)\sum_i B_{ii}^2\,\mathrm{Var}(\varepsilon_i^2), which is 2∑iBii22\sum_i B_{ii}^2 for Gaussians and 0 for Rademacher (εi2=1\varepsilon_i^2 = 1). Hence Rademacher is never worse, and much better when the diagonal dominates (script 05, D=2D = 2).

Exercise 11 (bits per dimension). Glow reports 3.35 bits per dimension on CIFAR-10 (32×32×332 \times 32 \times 3, 8-bit). How many bits per image is that, and what would uniform dequantization of 8-bit data look like (noise range, preprocessing)? What is “bits per dimension” of our best flow on ShapeWorld?

Answer

3.35×3072=10,2913.35 \times 3072 = 10{,}291 bits per image. Dequantize with v=x+uv = x + u, u∼U[0,1)Du \sim U[0,1)^D, x∈{0..255}x \in \{0..255\}, then scale to [0,1)[0,1) by dividing by 256 — whose log-determinant −Dlog⁡256-D\log 256 must be included (bits per dimension then simply add 8). ShapeWorld: 94.7/288=0.3394.7/288 = 0.33 bits per dimension, against 17.80/288=0.06217.80/288 = 0.062 for the floor.

Exercise 12 (why depth?). In 2-D, why can a 2-layer AR flow be near-exact while 16 affine couplings are not? Give one change to the coupling flow that would close most of the gap.

Answer

The AR flow’s two layers are the chain rule p(x1)p(x2∣x1)p(x_1)p(x_2\mid x_1) with 20-component mixture CDFs — each conditional is maximally flexible, and nothing else is needed in 2-D. An affine coupling can only shift and scale xbx_b given xax_a, so a multimodal conditional (several eyes and arcs at one x1x_1) must be built from many alternating cuts. Replacing the affine transform by a flexible monotone one (mixture CDF with more components, or a spline) makes each coupling a full conditional density transform — in 2-D that turns two couplings into exactly the AR flow.


11. Further reading

From the slides

  • L. Dinh, D. Krueger, Y. Bengio. NICE: Non-linear Independent Components Estimation, 2014; L. Dinh, J. Sohl-Dickstein, S. Bengio. Density Estimation using Real NVP, ICLR 2017.
  • D. P. Kingma, P. Dhariwal. Glow: Generative Flow with Invertible 1x1 Convolutions, NeurIPS 2018.
  • J. Ho, X. Chen, A. Srinivas, Y. Duan, P. Abbeel. Flow++: Improving Flow-Based Generative Models with Variational Dequantization and Architecture Design, ICML 2019.
  • W. Grathwohl, R. T. Q. Chen, J. Bettencourt, I. Sutskever, D. Duvenaud. FFJORD: Free-form Continuous Dynamics for Scalable Reversible Generative Models, ICLR 2019.
  • T. Müller et al. Neural Importance Sampling, 2018 (piecewise-polynomial couplings); C.-W. Huang et al. Neural Autoregressive Flows, 2018; R. T. Q. Chen et al. Residual Flows for Invertible Generative Modeling, NeurIPS 2019; Y. Song, C. Meng, S. Ermon. MintNet, NeurIPS 2019.
  • L. Theis, A. van den Oord, M. Bethge. A Note on the Evaluation of Generative Models, ICLR 2016 (uniform dequantization).
  • G. Papamakarios et al. Normalizing Flows for Probabilistic Modeling and Inference, JMLR 2021; I. Kobyzev et al. Normalizing Flows: An Introduction and Review of Current Methods, IEEE PAMI 2021.

Added by these notes

  • R. T. Q. Chen, Y. Rubanova, J. Bettencourt, D. Duvenaud. Neural Ordinary Differential Equations, NeurIPS 2018 (the instantaneous change of variables).
  • M. F. Hutchinson. A Stochastic Estimator of the Trace of the Influence Matrix for Laplacian Smoothing Splines, 1990.
  • C. Durkan, A. Bekasov, I. Murray, G. Papamakarios. Neural Spline Flows, NeurIPS 2019.
  • E. Hoogeboom, J. Peters, R. van den Berg, M. Welling. Integer Discrete Flows and Lossless Compression, NeurIPS 2019 — flows that stay discrete (no dequantization).
  • Y. Lipman et al. Flow Matching for Generative Modeling, ICLR 2023 — training continuous flows without simulating the ODE (Lectures 11–12).

12. Next lecture

Flows impose invertibility and pay for it: the latent has the data’s dimension, and every layer must be a bijection with a cheap determinant. Lecture 7 (latent variable models I) drops that constraint: a low-dimensional latent zz, a decoder p(x∣z)p(x \mid z) that need not be invertible, and p(x)=∫p(z) p(x∣z) dzp(x) = \int p(z)\,p(x \mid z)\,dz — which can no longer be computed exactly. We will see why sampling zz from the prior is a useless estimator, how importance sampling and an amortized encoder q(z∣x)q(z \mid x) fix it, derive the evidence lower bound twice (Jensen, and KL — the same bound as variational dequantization), compare likelihood-ratio and reparameterization gradients, and train VAEs on 2-D data (homework 2 Q1) and on ShapeWorld.

← 返回课程目录