Paper commentary
Density estimation using Real NVP
Real NVP learns invertible transformations that give exact likelihood and sampling
- Problem Generative models have struggled to offer exact likelihood, exact sampling and exact latent inference together. Each standard family gives up at least one, and the change of variable formula is costly for high-dimensional images.
- Method Real NVP stacks affine coupling layers, each with a triangular Jacobian, across multi-scale squeezing steps. It trains the stack by maximum likelihood, so the determinant stays cheap to compute.
- Results Real NVP reaches 3.49 bits/dim on the CIFAR-10 test set, against 3.00 for PixelRNN. Its validation scores are close to PixelRNN's but do not beat it.
Why exact likelihood is hard to get
Generative models are attractive for unsupervised learning because they can produce new content and also support reconstruction tasks such as inpainting, denoising and colorization. Undirected graphical models such as Restricted Boltzmann Machines and Deep Boltzmann Machines need approximate inference and Markov Chain Monte Carlo, because the marginal over latent variables is intractable, and these approximations can produce highly correlated samples.
Directed models sample by ancestral sampling, which is simple, but posterior inference over their latent variables is cumbersome, so variational autoencoders rely on an approximate inference network and a lower bound on the log-likelihood.
Autoregressive models keep the likelihood exact by factoring the joint distribution into conditionals over a fixed ordering of dimensions, but they have no natural latent representation and their sampling is sequential. GANs avoid the likelihood altogether and train a discriminator to supply the training signal, which yields sharp samples, while diversity is hard to measure and training can be unstable.
A bijection trained with the change of variable formula would keep the likelihood exact, but the Jacobian determinant is expensive for high-dimensional inputs, and naive use gives models that are computationally costly and poorly conditioned.
How an affine coupling layer keeps the Jacobian cheap
The basic block splits a D-dimensional input at index d. The first d components pass through unchanged, and the remaining components are multiplied elementwise by exp of s applied to the first part, then shifted by t of the same first part. Here s and t map from the first d dimensions to the remaining D minus d dimensions, and the elementwise product is the Hadamard product.
Because the first part is copied unchanged, the Jacobian is triangular, so its determinant is the exponential of the sum of the entries of s evaluated on the first part.
Since the determinant does not involve the Jacobians of s or t, these two functions can be deep convolutional networks with no requirement that they be invertible. The inverse is obtained by subtracting t from the second part and multiplying by exp of minus s, which costs about as much as the forward pass, so sampling is as cheap as inference.
A single coupling layer leaves some components unchanged, so layers are composed in an alternating pattern in which the components left alone by one layer are updated by the next. The Jacobian of the composition is the product of the Jacobians of the layers, and its determinant is the product of their determinants, so the total determinant stays tractable.
The inverse of the composition applies the inverse of each layer in reverse order.
Squeezing and factoring out across scales
The squeezing operation folds each 2x2 block of spatial positions into the channel axis, so an s x s x c tensor becomes an s/2 x s/2 x 4c tensor, trading spatial size for channels. Each scale applies three coupling layers with alternating checkerboard masks, then a squeeze, then three coupling layers with alternating channel-wise masks, and the final scale uses four checkerboard coupling layers.
The channel-wise masks are chosen so that their partition is not redundant with the checkerboard partition used before the squeeze.
Pushing the full D-dimensional vector through every layer would be costly in computation, memory and parameters, so half of the dimensions are factored out at regular intervals and modeled directly as Gaussians. The recursion starts from h^(0) equal to x, and at each level a function f^(i+1) produces the factored-out part z^(i+1) together with the part h^(i+1) that is passed on; the final latent code concatenates all z^(i).
Because units factored out at a finer scale are Gaussianized before those at a coarser scale, the intermediate levels capture more local features, and the loss is spread through the network.
Normalization, data transform and training setup
The scale and translation networks are deep residual networks with batch normalization and weight normalization, and batch normalization is also applied to the whole coupling layer output. Batch normalization acts as a per-dimension linear rescaling, so its Jacobian contributes a constant factor: the determinant equals the product over dimensions of the estimated variance plus epsilon, raised to the power minus one half.
The authors use a running average of recent minibatch statistics, with the current batch passed gradient only through its own statistics, which they report helps training with very small minibatches.
Horizontal flips of the training examples are added for CIFAR-10, CelebA and LSUN. The prior is an isotropic unit norm Gaussian, and the model is trained with ADAM at default hyperparameters, with an L2 penalty of 5 times 10 to the minus 5 on the weight scale parameters.
The batch size is 64, and the residual network depth and width depend on the dataset: 32x32 images use 4 residual blocks with 32 feature maps in the first coupling layers, 64x64 images use 2 residual blocks, and CIFAR-10 uses 8 residual blocks with 64 feature maps and a single downscaling. Each run used one of the listed settings; the paper does not report a search over these values.
Bits per dimension against PixelRNN and other models
On the CIFAR-10 test set Real NVP reaches 3.49 bits/dim, against 3.00 for PixelRNN, so for this lower-is-better metric PixelRNN is better. On the Imagenet 32x32 validation set Real NVP reaches 4.28 bits/dim against PixelRNN's 3.86, and on the 64x64 validation set it reaches 3.98 against 3.63. Table 1 also gives validation values for LSUN and CelebA, for example 2.72 for the bedroom category, where no PixelRNN figure is listed.
The authors summarise that the bits per dimension does not improve over the PixelRNN baseline but is competitive with other generative methods. The authors observe that performance rises with the number of parameters and expect larger models to improve further. For CelebA and LSUN the validation bits per dimension kept decreasing during training, so little overfitting is expected there.
Samples and the latent manifold
The authors describe the samples as globally coherent and sharp, and they attribute the sharpness to the model not relying on a fixed-form reconstruction cost such as an L2 norm, which tends to favour low frequency components. Sampling is parallelised over input dimensions, which the authors contrast with the sequential sampling of autoregressive models.
Because maximum likelihood values diversity over sample quality, some samples are highly improbable, which the authors notice especially on CelebA.
To probe the latent space, four validation latent codes z1 to z4 define a manifold through two angles phi and phi prime, with z equal to cos phi times the sum of cos phi prime z1 and sin phi prime z2, plus sin phi times the sum of cos phi prime z3 and sin phi prime z4. This manifold is mapped back to data space by computing g of z, and the authors observe that the learned latent organisation carries a meaning beyond pixel-space interpolation.
A class-conditional version trained on CelebA, whose invertible function takes the attribute labels as parameters, is reported to have a latent representation with a consistent semantic meaning across class labels.
Limitations
On the CIFAR-10 and Imagenet rows of Table 1 where PixelRNN is reported, Real NVP's bits per dimension is higher, and the authors do not present a larger model that closes this gap. The expectation that larger models would improve performance is the authors' hypothesis and is not tested in the reported models.
Some samples are highly improbable, and the authors note this especially for CelebA. The semi-supervised use of the latent space, which the authors consider a promising direction, was not tested in the paper and is left for future work. The class-conditional latent analysis is limited to CelebA and to the qualitative consistency described.
Paper info
- Authors
- Laurent Dinh, Jascha Sohl-Dickstein, Samy Bengio
- Venue
- arXiv · Preprint
- First published
- 2016-5-27
- Added
- 2026-11-6
- Updated
- 2017-2-27
- Version
- v3
- arXiv
- 1605.08803
- Category
- cs.LG · cs.AI · cs.NE · stat.ML
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Laurent Dinh, Jascha Sohl-Dickstein, Samy Bengio (2016). Density estimation using Real NVP. arXiv:1605.08803v3. https://arxiv.org/abs/1605.08803v3
BibTeX
@misc{dinh2016density,
title = {{Density estimation using Real NVP}},
author = {Laurent Dinh and Jascha Sohl-Dickstein and Samy Bengio},
year = {2016},
eprint = {1605.08803},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1605.08803v3}
}