TL;DR
The importance weighted autoencoder, or IWAE, uses the same two networks as a variational autoencoder: a generative network that builds data from hidden codes, and a recognition network that guesses the codes for a given input. Only the training target changes. Instead of the VAE's bound, which uses one sample per input, the IWAE averages several importance weights inside a logarithm. That bound is tighter, and it rises as the number of samples grows.
On the MNIST and Omniglot handwriting datasets, IWAEs reached better held-out log-likelihood than VAEs with the same architecture and about the same training time. They also used more of their latent dimensions, which the authors read as a richer hidden representation.
Builds on: Variational Autoencoder, Importance Sampling · Leads to: Normalizing Flow, which the paper names as another route to a more flexible posterior
Why it mattered
The VAE was new when this paper appeared, and it became one of the main recipes for deep generative models. This paper showed that the VAE objective itself was holding those models back. Its strict penalty on posterior samples that fail to explain the data pushed the model toward simple hidden codes, and many latent dimensions went unused. Changing only the objective, with the architecture kept fixed, let the same networks use more of their capacity.
The paper's numbers were competitive with the best models of its time. On MNIST with two stochastic layers and 50 samples, the IWAE reached a log-likelihood of -82.90 nats per image. The paper compares this with -84.55 for deep belief networks, -84.13 for deep autoregressive networks, and -80.97 for a model by Gregor and colleagues that exploited spatial structure. The bound also travels beyond this model: the authors note that reweighted wake-sleep (Bornschein and Bengio, 2015) is related but trained on a different target, and that Dinh and Dumoulin had independently explored an importance weighted bound for VAEs, presented in preliminary form at a 2014 summer school.
The problem
Training a latent-variable model by maximum likelihood needs the posterior, the distribution over hidden codes given the data. For most models that posterior is intractable, so the model is trained on a lower bound that uses an approximate posterior . The VAE uses the bound
The paper points out that the gap between this bound and the true log-likelihood is a KL divergence between the approximate and the true posterior. Maximising the bound therefore forces a trade-off: it raises the data log-likelihood and also pulls toward a shape that is easy to predict with a neural network.
That shape is the cost. The VAE assumes the posterior is roughly factorial, meaning the hidden dimensions are independent, and that its parameters can be predicted by a feedforward network. The bound is tight only if those assumptions hold, and it punishes any sample that lands where the true posterior has mass but the approximation does not. The authors argue that a recognition network which puts only a fraction of its samples in the good region can still do accurate inference, if the objective allows it. The question is how to get a training signal that does not punish those samples so hard.
How it works
Take one input and draw hidden codes from the recognition network. Suppose the three importance weights the model produces are , and .
- Draw several codes for one input. The recognition network gives a distribution over codes. Draw codes, , and . Check: each code is a full hidden vector, and the three are independent draws.
- Score each code with a weight. For each code compute . Suppose the three weights are , and . Check: a weight above 1 means the model likes that code more than the recognition network expected.
- Average the weights. . Check: this average is an unbiased estimate of , the quantity we want.
- Take the log of the average. . This is the IWAE objective for this input. Check: the log sits outside the average, not inside it.
- Compare with averaging the logs. The logs of the weights are , and . Their average is , which is what the VAE-style estimate gives over three draws. Check: is larger than , so the IWAE objective is the tighter of the two.
- Learn from normalised weights. Divide each weight by the total to get , and , which sum to 1. The gradient for the model is a weighted sum of the per-sample gradients using these numbers. Check: the sample with the largest weight moves the model most, and the sample with the smallest weight moves it least.
flowchart LR X[Input x] --> R[Recognition network] R --> H[k codes h_1 to h_k] H --> W[Weights w_i = p of x and h_i over q of h_i given x] W --> A[Average the k weights] A --> L[Log of the average is the objective] W --> G[Normalised weights steer the gradient]
The shape of the objective explains the gain. The plot shows of the three weights from the walkthrough, and the point where the log of their average falls.
- log x
The math
The IWAE bound with samples is
Here is one observed image, is a hidden code drawn from the recognition network, and is that code's importance weight. The expectation averages over all possible sets of draws.
Step 1 in symbols: the samples and weights
Draw independently from , then compute for each. With the sum has one term and the bound becomes , which is the VAE bound. So the VAE is the special case .
Step 2 in symbols: the average inside the log
The weights are averaged, , and the logarithm is taken of that average. Swapping the order of average and log would give , the VAE-style estimate. Taking the log after the average is what makes the bound tighter.
Step 3 in symbols: why the bound is valid
Since , the average of the weights is an unbiased estimate of . Jensen's inequality for the concave logarithm, , then gives
The bound never overshoots the true log-likelihood.
Step 4 in symbols: more samples never hurt
The paper proves that the bounds never decrease as grows,
The argument applies Jensen's inequality again, to a random subset of samples drawn from the available. If the weights are bounded, approaches as goes to infinity.
Step 5 in symbols: the gradient and normalised weights
Let . The gradient of the bound with respect to the model parameters is estimated by
Each sample's gradient is weighted by , so samples that explain the data well have more influence. The weights sum to 1. When the single normalised weight is 1 and the rule reduces to the VAE update.
Step 6 in symbols: the reparameterised sample
To take gradients through the sampling step, the paper writes each code as a deterministic function of the input and noise. For a Gaussian layer,
Here and are the mean and covariance produced by the network, and is noise that does not depend on the parameters. This is the reparameterization trick applied to every sample.
Results
Density estimation on MNIST and Omniglot. The paper reports negative log-likelihood in nats, so lower is better. Two stochastic layers, , gave the following. On MNIST the VAE reached 84.78 and the IWAE 82.90, a gap of nats. On Omniglot the VAE reached 106.30 and the IWAE 103.38, a gap of nats. The best Omniglot IWAE, at -103.38 nats, is slightly worse than the -100.46 nats of a restricted Boltzmann machine with 500 hidden units trained with persistent contrastive divergence, so the claim is about the VAE comparison, not state of the art on that dataset.
The gap grows with k. With one stochastic layer on MNIST, the VAE and IWAE are identical at (both 86.76), which the theory predicts. At the VAE reaches 86.47 and the IWAE 85.54, a gap of 0.93 nats. At the VAE reaches 86.35 and the IWAE 84.78, a gap of 1.57 nats. The VAE gains only slightly from more samples, while the IWAE keeps improving, as Step 4 of the math predicts.
Latent dimensions in use. Table 1 also counts active latent units, where a unit is active when its posterior mean varies across inputs. For two layers on MNIST with , the VAE uses 17+5 units and the IWAE uses 26+7. In every case with , the IWAE learned more active dimensions than the VAE. The authors read this as a richer latent representation, which coincided with higher likelihood.
Is the objective or the optimiser to blame? Table 2 swaps objectives after training. The VAE, trained to 86.76 with 19 active units, reached 84.88 with 22 units after more training with the IWAE objective at . The IWAE, trained to 84.78 with 25 active units, fell to 86.02 with 23 units after training with the VAE objective. Switching objectives moves both quantities in the same direction. The authors conclude that the objective, not poor optimisation, drives the unused units, though optimisation plays some role.
Limits. The experiments use two small benchmarks with binarised images, and the paper notes that binarisation choices change likelihood values a lot, so comparisons must share a protocol. Overfitting was mild, with training log-likelihood 0.62 to 0.79 nats above test on MNIST. The basic update costs forward and backward passes per example, so training time grows with . Each of the samples passes through the networks on its own. The single-sample variant from the paper needs forward passes and one backward pass per example, roughly a factor of 3 saving for large , at the price of higher gradient variance; the authors found that trade-off favourable. The paper also notes that the VAE trick of splitting out the KL term has no clean counterpart for , so the IWAE update may have higher variance in principle, although the two updates performed indistinguishably at . Appendix B argues that the log of the average does not suffer the huge variance usually associated with importance weights: the mean absolute deviation of the estimate is bounded by , where is the gap between the bound and the true log-likelihood.
Reading guide
Read the paper in this order, with these lessons in hand.
- Abstract and Section 1 (Introduction). Needs Variational Autoencoder and Latent Variable Model.
- Section 2 (Background). The VAE recap. Needs Variational Lower Bound (ELBO), Kullback–Leibler Divergence, Gaussian (Normal) Distribution and Reparameterization Trick. Take the factorial posterior assumption as the constraint the paper is trying to relax.
- Section 3 (Importance Weighted Autoencoder). The core idea. Needs Importance Sampling, Monte Carlo Method and Jensen's Inequality. Work Theorem 1 with Appendix A beside you.
- Section 3.1 (Training procedure). The gradient and normalised weights. Needs Backpropagation and Stochastic Gradient Descent.
- Appendix B. The variance argument. Needs Importance Sampling and the idea of an estimator's variance.
- Section 4 (Related work). Read after Amortized Inference and Mean-Field Approximation, which explain the recognition-network family, and Normalizing Flow, the paper's named alternative.
- Section 5 (Experimental results). The tables. Needs Adam Optimizer for the training setup and Monte Carlo Method for how the test log-likelihood is estimated.
Check yourself
QuestionRecall: with a single sample, , what does the IWAE bound reduce to?Show answer
QuestionComputation: two importance weights are and . What is the IWAE objective for this input, and what is the average of the logs?Show answer
QuestionWhy: why does the IWAE bound improve as the number of samples grows, while the VAE bound gains only a little?Show answer
QuestionApplied: the basic IWAE update costs forward and backward passes per example. Why might the authors' single-sample variant be preferred for large , and what does it cost?Show answer
Sources
- Burda, Grosse, Salakhutdinov, Importance Weighted Autoencoders, arXiv:1509.00519 (2015), https://arxiv.org/abs/1509.00519
- Kingma and Welling, Auto-Encoding Variational Bayes, arXiv:1312.6114 (2013), https://arxiv.org/abs/1312.6114