Back to paper library
Paper notesarXiv 2016NeurIPS 2016

Ladder VAE

Is the Floor Above Right?

Original paper

Ladder Variational Autoencoders

Paper authors

Casper Kaae Sønderby · Tapani Raiko · Lars Maaløe · Søren Kaae Sønderby · Ole Winther

Publication
NeurIPS 2016Conference
First submitted to arXiv
arXiv:1602.02282
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{imagegenerationladdervae2016,
  title = {{Ladder Variational Autoencoders}},
  author = {Casper Kaae Sønderby and Tapani Raiko and Lars Maaløe and Søren Kaae Sønderby and Ole Winther},
  year = {2016},
  eprint = {1602.02282},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1602.02282}
}
On this page

The first version of this paper on arXiv was titled "How to Train Deep Variational Autoencoders and Probabilistic Ladder Networks." The abstract listed three improvements: an inference model modeled on the Ladder Network, a warm-up period, and batch normalization. The three stood on equal footing, and the goal was to stack a VAE five layers of stochastic latent variables deep for the first time.

In the second version, a little over three months later, the title was down to just "Ladder Variational Autoencoders." Warm-up and BN were still there, demoted to the observation that they are "crucial for training variational models with many stochastic layers." The README of the official repo still carries the old title from the first version.

This note takes all three apart. First, where multilayer VAEs get stuck; then how LVAE's inference combines the prior handed down from "the floor above" with the evidence from the data; and last, whether all five layers of latent variables are really doing any work.

Defining the Problem

Stacking more layers of latent variables

The original VAE has a single set of latent variables zz with a standard normal prior, and the decoder generates xx from zz. A hierarchical VAE splits the latent variables into LL layers: the top layer zLz_L is sampled from a standard normal, each layer below is a Gaussian conditioned on the layer above it, and finally z1z_1 generates the image:

pθ(z)=pθ(zL)∏i=1L−1pθ(zi∣zi+1)pθ(zL)=N(0,I)\begin{aligned} p_\theta(z)&=p_\theta(z_L)\prod_{i=1}^{L-1}p_\theta(z_i\mid z_{i+1})\\ p_\theta(z_L)&=\mathcal N(0,I) \end{aligned} pθ(zi∣zi+1)=N ⁣(μp,i(zi+1), σp,i2(zi+1))p_\theta(z_i\mid z_{i+1})=\mathcal N\!\big(\mu_{p,i}(z_{i+1}),\ \sigma^2_{p,i}(z_{i+1})\big)

The subscript pp marks this mean and variance as belonging to the generative model; the inference model's will carry the subscript qq later. Each conditional distribution is a diagonal Gaussian whose dimensions are independent of each other; but once the layers are stacked, the marginal distribution of z1z_1 can have strong correlations, while the computation still only ever deals with diagonal Gaussians. The observation model pθ(x∣z1)p_\theta(x\mid z_1) is Bernoulli on binary images such as MNIST and Gaussian on the grayscale NORB.

The paper's largest model has five layers, with latent dimensions 64, 32, 16, 8, 4 from bottom to top.

Upper layers are trained only through the KL

Write out the ELBO for the two-layer case first. Standard VAE inference runs bottom-up, inferring z1z_1 from xx and then z2z_2 from z1z_1, q(z∣x)=q(z1∣x) q(z2∣z1)q(z\mid x)=q(z_1\mid x)\,q(z_2\mid z_1). Substitute this into the ELBO's definition Eq[log⁡p(x,z)−log⁡q(z∣x)]\mathbb E_q[\log p(x,z)-\log q(z\mid x)] and split the joint distribution into three factors:

L=Eq[log⁡p(x∣z1)+log⁡p(z1∣z2)  +log⁡p(z2)−log⁡q(z1∣x)  −log⁡q(z2∣z1)]=Eq[log⁡p(x∣z1)]−Eq[log⁡q(z1∣x)−log⁡p(z1∣z2)]−Eq[log⁡q(z2∣z1)−log⁡p(z2)]\begin{aligned} \mathcal L &=\mathbb E_q\big[\log p(x\mid z_1)+\log p(z_1\mid z_2)\\ &\qquad\;+\log p(z_2)-\log q(z_1\mid x)\\ &\qquad\;-\log q(z_2\mid z_1)\big]\\ &=\mathbb E_q\big[\log p(x\mid z_1)\big]\\ &\quad-\mathbb E_q\big[\log q(z_1\mid x)-\log p(z_1\mid z_2)\big]\\ &\quad-\mathbb E_q\big[\log q(z_2\mid z_1)-\log p(z_2)\big] \end{aligned}

The first term is the reconstruction term; each of the other two measures how far one layer's approximate posterior is from its prior, i.e., each layer's KL term (with the sampled layer above inside the expectation).

Look at where z2z_2 shows up. It is absent from the reconstruction term and appears only in the last two terms. The job of z2z_2 is to give z1z_1 a better prior p(z1∣z2)p(z_1\mid z_2) so that the second term shrinks; it makes no direct contribution to reconstruction. The first author said the same when answering a question in issue #1 of the official repo, describing the upper layers as trained only indirectly through the KL term and only trying to match the distribution of the layers below, and calling this one of the weaknesses of VAEs.

That leads to the first bottleneck. Break the ELBO down further and each layer's KL can be split across its individual latent units. If a unit zi,kz_{i,k} has a KL of 0, its approximate posterior is identical to the prior; whatever image comes in, it outputs the same distribution and carries no information about the data, and the paper calls it an inactive unit. Early in training, reconstruction is still poor, and for the upper layers pushing the KL to 0 is the cheapest way to lower the loss. The authors observed that units that collapse this early almost never wake up for the rest of training, as if stuck in a local minimum or saddle point at KL≈0\mathrm{KL}\approx0.

The second bottleneck is in the inference network itself. The bottom-up q(z2∣z1)q(z_2\mid z_1) and the generative p(z1∣z2)p(z_1\mid z_2) are two unrelated networks, and neither can see the other. Early in training the generative distribution moves around a lot, and the inference network has to chase it on its own to keep each layer's KL small.

Before this paper, VAEs mostly used just one or two layers of stochastic latent variables; the authors found that purely bottom-up inference trained with gradient methods could only partly use even two.

So the question this paper answers is whether, with the generative model left alone, a different inference model can put all five layers of latent variables to work.

Solving the Problem

Two passes

Two sets of directed graphs. a) is the VAE: on the left, the inference model points upward from x to z1 and then to z2; on the right, the generative model goes down from z2 to z1 and then to x. b) is the LVAE: on the left, a deterministic path first runs upward from x through the diamonds d1 and d2, d2 points to z2, z2 points down to z1, and d1 also points to z1; the generative model on the right is the same as in a), and the space between the two z2-to-z1 arrows is labeled shared.
Original Figure 1, Sønderby et al., from PDF page 2, arXiv license, scholarly quotation.

In the figure, circles are random variables and diamonds are deterministic features. On the left, a) is the standard VAE, where inference and generation run in opposite directions. On the right, b) is the LVAE, where inference takes two passes.

The first pass goes up and is entirely deterministic. Starting from d0=xd_0=x, each layer goes through a two-layer MLP, and then two linear layers read out that layer's estimates:

dn=MLP(dn−1)μ^q,i=Linear(di)σ^q,i2=Softplus(Linear(di))\begin{aligned} d_n&=\mathrm{MLP}(d_{n-1})\\ \hat\mu_{q,i}&=\mathrm{Linear}(d_i)\\ \hat\sigma^2_{q,i}&=\mathrm{Softplus}\big(\mathrm{Linear}(d_i)\big) \end{aligned}

Take the five-layer MNIST model. The 784-dimensional xx goes through an MLP of width 512 to get d1d_1, from which the 64-dimensional μ^q,1\hat\mu_{q,1} and σ^q,12\hat\sigma^2_{q,1} are read out; d1d_1 goes through an MLP of width 256 to get d2d_2, which gives 32-dimensional estimates; and so on up to d5d_5, which gives 4-dimensional estimates. Softplus is log⁡(1+eu)\log(1+e^{u}), which keeps the variance positive.

This pass only computes what each layer would guess "from the data alone"; nothing has been sampled yet.

The second pass goes down, sampling as it goes. The top layer uses the estimates from the upward pass directly, q(z5∣x)=N(μ^q,5,σ^q,52)q(z_5\mid x)=\mathcal N(\hat\mu_{q,5},\hat\sigma^2_{q,5}), and is sampled to get z5z_5. Then z5z_5 goes through the generative model's mapping, giving the generative model's prior for z4z_4, μp,4(z5)\mu_{p,4}(z_5) and σp,42(z5)\sigma^2_{p,4}(z_5). Layer 4 now holds two opinions, one from the data downstairs and one from the prior upstairs; it merges the two into the approximate posterior, samples z4z_4, and moves down another floor.

The whole approximate posterior thus has the same top-down structure as the generative model:

qϕ(z∣x)=qϕ(zL∣x)∏i=1L−1qϕ(zi∣zi+1,x)q_\phi(z\mid x)=q_\phi(z_L\mid x)\prod_{i=1}^{L-1}q_\phi(z_i\mid z_{i+1},x)

The "shared" between the two z2→z1z_2\to z_1 arrows in b) means that the second pass of inference reuses the generative model's mapping directly. The generative model is identical to the VAE's and the inference model has a similar number of parameters; the two differ only in how inference proceeds.

Precision weighting

How are the two opinions merged? Equations 17 and 18 of the paper read:

σq,i2=1σ^q,i−2+σp,i−2μq,i=μ^q,i σ^q,i−2+μp,i σp,i−2σ^q,i−2+σp,i−2\begin{aligned} \sigma^2_{q,i}&=\frac{1}{\hat\sigma^{-2}_{q,i}+\sigma^{-2}_{p,i}}\\[4pt] \mu_{q,i}&=\frac{\hat\mu_{q,i}\,\hat\sigma^{-2}_{q,i}+\mu_{p,i}\,\sigma^{-2}_{p,i}}{\hat\sigma^{-2}_{q,i}+\sigma^{-2}_{p,i}} \end{aligned}

The reciprocal of the variance, σ−2\sigma^{-2}, is called the precision. The new precision is the sum of the two precisions, and the new mean is the average of the two means weighted by their precisions.

These formulas come from multiplying two Gaussians. The authors treat the estimate from downstairs as an approximate Gaussian likelihood and the prior from upstairs as a Gaussian prior, and the posterior is proportional to their product. For a single dimension, dropping the constants that don't depend on zz:

N(z;μ^,σ^2)⋅N(z;μp,σp2)∝exp⁡ ⁣(−(z−μ^)22σ^2−(z−μp)22σp2)\begin{aligned} &\mathcal N(z;\hat\mu,\hat\sigma^2)\cdot\mathcal N(z;\mu_p,\sigma_p^2)\\ &\quad\propto\exp\!\Big(-\frac{(z-\hat\mu)^2}{2\hat\sigma^2}-\frac{(z-\mu_p)^2}{2\sigma_p^2}\Big) \end{aligned}

Expand the two squares in the exponent and collect by powers of zz:

−12[(σ^−2+σp−2)z2−2(μ^ σ^−2+μp σp−2)z]+C\begin{aligned} -\frac12\Big[&\big(\hat\sigma^{-2}+\sigma_p^{-2}\big)z^2\\ &-2\big(\hat\mu\,\hat\sigma^{-2}+\mu_p\,\sigma_p^{-2}\big)z\Big]+C \end{aligned}

The exponent of a Gaussian N(z;m,s2)\mathcal N(z;m,s^2) expands to −12[s−2z2−2ms−2z]+C′-\frac12\big[s^{-2}z^2-2ms^{-2}z\big]+C'. Matching term by term, the coefficient of z2z^2 gives s−2=σ^−2+σp−2s^{-2}=\hat\sigma^{-2}+\sigma_p^{-2}, and the coefficient of zz gives m s−2=μ^ σ^−2+μp σp−2m\,s^{-2}=\hat\mu\,\hat\sigma^{-2}+\mu_p\,\sigma_p^{-2}. Dividing one by the other gives the μq,i\mu_{q,i} above.

Run the numbers twice for one unit. Suppose the prior from upstairs is μp=0\mu_p=0, σp2=1\sigma_p^2=1, with precision 1.

  • Downstairs is confident: μ^=2\hat\mu=2, σ^2=0.25\hat\sigma^2=0.25, precision 4. The merged precision is 5, σq2=0.2\sigma_q^2=0.2, μq=(2×4+0×1)/5=1.6\mu_q=(2\times4+0\times1)/5=1.6. The data pulls the posterior almost all the way over.
  • Downstairs isn't sure: μ^=2\hat\mu=2, σ^2=4\hat\sigma^2=4, precision 0.25. The merged precision is 1.25, σq2=0.8\sigma_q^2=0.8, μq=(2×0.25)/1.25=0.4\mu_q=(2\times0.25)/1.25=0.4. The posterior stays roughly near the prior.

Next, compute this unit's KL. The KL between two one-dimensional Gaussians has a closed form:

KL(N(μq,σq2) ∥ N(μp,σp2))=log⁡σpσq+σq2+(μq−μp)22σp2−12\begin{aligned} &\mathrm{KL}\big(\mathcal N(\mu_q,\sigma_q^2)\,\|\,\mathcal N(\mu_p,\sigma_p^2)\big)\\ &\quad=\log\frac{\sigma_p}{\sigma_q}+\frac{\sigma_q^2+(\mu_q-\mu_p)^2}{2\sigma_p^2}-\frac12 \end{aligned}

The first case gives 12ln⁡5+0.2+2.562−12≈0.805+1.380−0.5=1.685\tfrac12\ln5+\tfrac{0.2+2.56}{2}-\tfrac12\approx0.805+1.380-0.5=1.685 nats; the second gives 12ln⁡1.25+0.8+0.162−12≈0.112+0.480−0.5=0.092\tfrac12\ln1.25+\tfrac{0.8+0.16}{2}-\tfrac12\approx0.112+0.480-0.5=0.092 nats.

This is what the paper means when it says the downward pass "recursively corrects the generative distribution" with the data. Upstairs first states the generative model's current view, and the posterior is pushed toward the data as far as downstairs' confidence warrants; how much KL this unit pays for this image follows downstairs' confidence as well. The inference network doesn't have to rebuild a distribution close to the prior from scratch, because its starting point is the prior itself.

Top-down sampling has a computational bonus too. Once zi+1z_{i+1} has been sampled, q(zi∣zi+1,x)q(z_i\mid z_{i+1},x) and p(zi∣zi+1)p(z_i\mid z_{i+1}) are both diagonal Gaussians with known parameters, so this layer's KL can use the closed form above directly, summed over the dimensions.

Warm-up

The second improvement deals with units collapsing too early. The authors put a coefficient β\beta in front of the KL term:

LT(θ,ϕ;x)=−β KL(qϕ(z∣x) ∥ pθ(z))+Eqϕ(z∣x)[log⁡pθ(x∣z)]\begin{aligned} \mathcal L_T(\theta,\phi;x)={}&-\beta\,\mathrm{KL}\big(q_\phi(z\mid x)\,\|\,p_\theta(z)\big)\\ &+\mathbb E_{q_\phi(z\mid x)}\big[\log p_\theta(x\mid z)\big] \end{aligned}

Training starts at β=0\beta=0, which rises linearly to 1 over the first NtN_t epochs, after which the objective is the original ELBO. For MNIST, training runs for 2,000 epochs in total, with warm-up over the first 200.

At β=0\beta=0 only the reconstruction term is left and the variance of the approximate posterior carries no penalty, so the best solution shrinks the noise to 0, and the model is a deterministic autoencoder. The authors describe this starting point as a delta-function solution at zero temperature. As β\beta grows, the KL starts pulling each unit toward the prior; units that already learned useful representations during the autoencoder phase have a reason to resist that pull. In the official code, log⁡p(z)−log⁡q(z)\log p(z)-\log q(z) is simply multiplied by a temperature that rises from 0 to 1.

Batch normalization

The third improvement adds BN to every MLP in both the VAE and the LVAE. BN injects noise between mini-batches during training, which doesn't sound like a good idea for a model that already runs on sampling; the authors say in their conclusion that they were surprised BN helped this much and don't yet fully understand why.

Experimental setup

Three datasets:

  • MNIST: 28×28 handwritten digits, a Bernoulli observation model and leaky ReLU activations (max⁡(x,0.1x)\max(x,0.1x)). Trained for 2,000 epochs with learning rate 0.001. As in IWAE, the binarized training images are resampled from the grayscale values every epoch to avoid overfitting.
  • OMNIGLOT: 28×28 binary images of 50 alphabets, with 20 handwritten samples per character, trained for 1,500 epochs.
  • NORB: 32×32 grayscale images of five kinds of toy objects under different lighting and angles, a Gaussian observation model and tanh activations.

All mappings are two-layer MLPs, with width 512 between xx and the first layer and then 256, 128, 64, 32 going up; the VAE and LVAE use the same widths, and shallower models simply drop the top layers. The optimizer is Adam, with batch size 256 and 1 Monte Carlo sample during training.

Two numbers are reported. L1\mathcal L_1 is the ELBO with 1 sample; L5000\mathcal L_{5000} is the importance-weighted bound with 5,000 samples, much tighter than the ELBO, which the paper uses as an approximation of the true log-likelihood. Both are in nats, and higher is better; the gap between them can be read as how far the inference model still is from the true posterior.

Discussion

MNIST: adding one layer at a time

Three line charts, each with the number of stochastic latent layers, 1 to 5, on the horizontal axis and log-likelihood on the vertical axis. a) L1 on the training set: orange LVAE+BN+WU rises from about −89.4 to about −84.3, the other three stay between −87 and −88, and red VAE drops after two layers. b) L1 on the test set: LVAE rises to about −85.2; green VAE+BN and purple VAE+BN+WU almost overlap, leveling off at about −87.5; red VAE sits between −90.4 and −91.2 and gets worse with more layers. c) L5000 on the test set: LVAE is highest at about −82.1, purple about −82.8, green about −83.4, red about −85.6.
Original Figure 3, Sønderby et al., from PDF page 4, arXiv license, scholarly quotation.

The horizontal axis is the number of stochastic latent layers and the vertical axis is log-likelihood. The four lines are the VAE without BN or warm-up (red), with BN (green), with warm-up added as well (purple), and the LVAE, also with BN and warm-up (orange).

Start with the test-set L1\mathcal L_1 in the middle panel, b). The red line never improves after one layer and gets worse the more layers it has; the extra latent variables are of no use to it at all. The green and purple lines level off after two or three layers, at around −87.5; in this plot they almost overlap. The orange line goes up with every added layer, reaching −85.23 at five layers, 2.26 nats above the best VAE (three layers, −87.49).

Then look at L5000\mathcal L_{5000} in panel c) on the right. The LVAE is at −82.12 and the best VAE at −82.74, and the gap shrinks to 0.62 nats.

The two gaps only get interesting when read together. The two models have the same generative architecture; L5000\mathcal L_{5000} is closer to the true log-likelihood and measures the learned generative model itself, while L1\mathcal L_1 also includes the inference model's error. Of the LVAE's 2.26 nats, about 0.62 nats come from a better generative model and the rest from a tighter bound, that is, an approximate posterior closer to the true posterior. As the paper puts it, the LVAE gets both a higher log-likelihood and a significantly tighter lower bound.

Also, the purple and green lines nearly overlap in b) and only separate in c); at five layers, warm-up lifts L5000\mathcal L_{5000} from about −83.4 to about −82.8 (read off the plot). What warm-up mainly improves is the learned generative model; it has almost no effect on the 1-sample ELBO.

The authors then fine-tuned the five-layer LVAE for another 2,000 epochs, multiplying the learning rate by 0.75 every 200 epochs and raising both the Monte Carlo and the importance-weighted sample counts to 10, and compared it with other methods of the time:

Model≤log⁡p(x)\le\log p(x)
VAE, 1 layer + normalizing flow−85.10
IWAE, 2 layers, IW=1−85.33
IWAE, 2 layers, IW=50−82.90
VAE, 2 layers + VGP−81.90
LVAE, 5 layers−82.12
LVAE, 5 layers, fine-tuned−81.84
LVAE, 5 layers, fine-tuned, IW=10−81.74

Compiled from Table 1 of the paper, MNIST test set.

Trained with just 1 sample, the LVAE already beats the IWAE trained with 50 importance-weighted samples by 0.78 nats; the variational Gaussian process (VGP) at −81.90 is only overtaken once the LVAE is fine-tuned. The authors themselves note that these methods use different training procedures, so the numbers in the table are not directly comparable. They also say that none of the models showed any overfitting.

Who is doing the work

Four groups of heat maps, each running from layer 5 at the top to layer 1 at the bottom, with epochs 1 to 2000 on the horizontal axis; each row is one latent unit and the color is log KL, with white meaning the unit is inactive. In the VAE, only a small block at the bottom of layer 1 and one line in layer 2 are dark, and layers 3 to 5 are entirely white. In VAE+BN, the dark area of layer 1 is larger, layer 2 has a narrow band at the bottom, and layer 3 is down to a single line. In VAE+BN+WU, every layer has large dark areas early in training that gradually turn white; in the end layers 1 and 2 keep more, layers 3 and 4 keep only a few lines each, and layer 5 turns completely white after a while. LVAE+BN+WU keeps large dark areas in all five layers, and layer 5 is almost entirely dark.
Original Figure 4, Sønderby et al., from PDF page 6, arXiv license, scholarly quotation.

As mentioned earlier, each unit's KL can be pulled out on its own. This figure draws every unit of the five-layer MNIST models as a row, with training epochs on the horizontal axis and log KL as the color; the whiter, the closer to 0, i.e., the less active. Units within each layer are sorted by magnitude.

In the standard VAE, layers 3 to 5 are white from start to finish, and layer 2 has only one line left. With BN, layer 1 has more active units and layer 3 gets a line too. With warm-up, every layer starts as a large dark patch early in training; then the weight of the KL term rises and units get pruned one by one, but more of them survive in the end than without warm-up, and the representation is more distributed. Without warm-up, each unit's KL barely changes over the whole of training; whatever collapsed at the start never woke up again.

The LVAE keeps large swaths of active units in all five layers, and the 4 units of layer 5 are working almost the whole time.

Summing the units of a layer gives the per-layer KL, which can be read as how much information each layer encodes for an image.

The standard VAE puts almost all the information in layer 1, about 22 nats, with under 2 nats in layer 2 and 0 above that. The VAEs with BN or warm-up use one or two more layers, but layer 1 still takes most of it, about 19 nats. The LVAE's layer 1 has only about 7.6 nats, layer 2 about 8.6, layer 3 about 3.6, layer 4 under 1, and the top layer still about 4.2. Summed over five layers, the LVAE has about 25 nats, close to the standard VAE's roughly 24; what it does is move a similar amount of information up into the higher layers.

A grid of scatter plots, 5 rows by 4 columns; each row is layer i (i=5 to 1 from top to bottom) and each column is one model. Point colors represent the true MNIST digits 0 to 9. In the VAE column, layers 3 to 5 are round clouds with the colors all mixed. VAE+BN starts showing band-like structures separated by color at layer 3. VAE+BN+WU shows clusters at layer 4, while layer 5 is still a mixed cloud. In the LVAE+BN+WU column, the points of layer 5 split clearly by color into several fan-shaped groups, and layers 4 and 3 also show clear clusters.
Original Figure 6, Sønderby et al., from PDF page 8, arXiv license, scholarly quotation.

Last comes a qualitative check. The authors sample from each layer's approximate posterior, project the samples to two dimensions with PCA, and color them by the true digit class.

In the standard VAE, everything above layer 2 is a standard normal cloud with the colors completely mixed, meaning these layers have collapsed back to the prior. BN and warm-up each bring one more layer back to life. The LVAE has structure in all five layers, and clusters more by class the higher you go; the 4 units of layer 5 already cut the ten digits into several fan-shaped pieces. From this the authors speculate that such upper-layer representations might be useful for semi-supervised learning.

OMNIGLOT and NORB

Beyond MNIST, here are the test-set log-likelihoods on the other two datasets. The left column is the number of latent layers; with one layer the LVAE is the same as the VAE, so that cell is left empty.

LayersVAE+BN+BN+WULVAE
1−111.21−105.62−104.51−
2−110.58−105.51−102.61−102.63
3−111.26−106.09−102.52−102.18
4−111.58−105.66−102.66−102.21
5−110.46−105.45−102.48−102.11

Compiled from Table 2 of the paper, OMNIGLOT.

On OMNIGLOT, the five-layer LVAE's −102.11 is the best result, and also above the best figure in the IWAE paper, −103.38; that IWAE used two latent layers of 100-50 and trained with 50 importance-weighted samples on top of that.

Read the table from left to right, though, and the two biggest jumps come from BN (five layers going from −110.46 to −105.45) and warm-up (on to −102.48). The LVAE adds only 0.37 nats on top of that.

LayersVAE+BN+BN+WULVAE
1274131983338−
22792322434833272
32786323534923519
42689320134823449
52654319834223455

Compiled from Table 2 of the paper, NORB.

The NORB numbers are positive because NORB uses a continuous Gaussian observation model; a probability density can exceed 1, so the log-likelihood can naturally be positive, and higher is still better. The LVAE does best at three layers, 27 above the VAE's best; but the two-layer LVAE is actually 211 below VAE+BN+WU. No model improves beyond three layers. The authors believe the Gaussian observation model is harder to optimize than the Bernoulli one, which may be why the upper layers get used less.

Three things that can't be pulled apart

Looking back over these experiments, one combination never shows up. Every LVAE is LVAE+BN+WU; there is no LVAE without warm-up, and none without BN. A figure caption in the appendix does slip in one sentence saying that the LVAE without BN performed very poorly, with some results falling outside the plot's range; but that line isn't drawn, and no numbers are given.

So we know LVAE with BN and warm-up is very good, and we know BN and warm-up help the VAE a lot by themselves, but we don't know how much the precision-weighting trick carries on its own. On OMNIGLOT the answer looks like not much. That is probably also why the first version's title listed all three side by side.

The official code

The official repo is written in Theano and Lasagne, and its README includes one command for the VAE and one for the LVAE.

Figure 1 of the paper draws "shared" between the two z2→z1z_2\to z_1 arrows of inference and generation, and the text stresses that the inference and generative models share information and parameters. Yet the README's LVAE command reads -ladder_share_params False (an arrow drawn in the figure, switched off on the command line). As the code is written, this setting gives the second inference pass a separate top-down MLP of its own, and the merge uses the mean and variance that MLP computes rather than the generative model's μp\mu_p and σp\sigma_p.

Someone asked in issue #1 whether the paper's results used the default parameters. The author answered on October 10, 2016 that the results in the NIPS version of the paper had been computed with slightly different code, "I'll hopefully get it online soon," and that the default parameters probably wouldn't give the paper's numbers. The repo's last commit is dated March 28, 2016, more than half a year before that reply (that "soon" is now ten years old). The next day the author added that the repo version and the paper's results should be within about 0.2 nats of each other; nobody in the issue reported verifying that number.

Conclusion

Ladder VAE changes only the inference model. One pass up computes each layer's evidence from the data, and one pass down combines it with the generative model's prior by precision weighting, so the approximate posterior starts from the "prior" and gets corrected outward according to how confident the data is. On MNIST it puts all five layers of latent variables to work, with L1\mathcal L_1 2.26 nats above the best VAE and L5000\mathcal L_{5000} 0.62 nats above it; on OMNIGLOT, most of the gain actually comes from BN and warm-up; on NORB, nobody gets past three layers.

When training a hierarchical VAE, if the upper layers' KL stays at 0, first plot each unit's KL the way Figure 4 does and see whether the units collapsed at the start or were pruned gradually, then decide whether to add warm-up, change the inference structure, or just stack fewer layers. This paper's experience is that units that collapse at the start almost never wake up on their own later.

Precision weighting itself was rarely copied afterward; what stuck was the top-down order of inference. Four years later, NVAE had the approximate posterior predict a relative shift and scale with the prior as its reference; VDVAE says outright that the top-down VAE it uses was introduced by Sønderby et al. In December 2020, a newcomer on VDVAE's GitHub couldn't tell encoder features from latent variables, and the advice VDVAE's author, Child, gave was to read the Ladder VAE paper first.