Paper commentary
Pixel Recurrent Neural Networks
Pixel recurrent networks predict each pixel of natural images in sequence
- Problem Modeling natural images needs a density that is expressive, tractable and scalable at once. Earlier latent variable models need an inference step that can be intractable and can limit performance.
- Method PixelRNN predicts each color value of each pixel as one of 256 discrete values with a softmax. Each pixel is conditioned on earlier pixels through Row LSTM or Diagonal BiLSTM layers, instead of assuming a continuous density.
- Results The Diagonal BiLSTM reaches 3.00 bits/dim on CIFAR-10 test without data augmentation. The Row LSTM reaches 3.07 on the same test, and the PixelCNN 3.14.
Why natural-image likelihoods are hard
Natural images are high dimensional and strongly structured, which makes their distribution hard to estimate. A model therefore has to be expressive enough to capture that structure while staying tractable and scalable to train.
Much earlier work relied on stochastic latent variable models such as VAEs, which aim at useful representations but need an inference step that can be intractable and can limit performance. Autoregressive models avoid such an inference step by writing the joint distribution as a product of conditionals, which turns image modeling into a sequence problem.
A sequence model in that setting has to capture highly nonlinear, long-range correlations between pixels, and recurrent networks offer a compact parameter sharing across the conditional distributions. Two-dimensional recurrent networks had already shown promise on grayscale images and textures, and this work pushes that line toward large-scale natural images.
Pixel-by-pixel factorization over discrete values
An n by n image is read row by row into a sequence of n squared pixels, and its probability is written as a product of conditionals, each given all earlier pixels. The joint is the product below, where each factor is the probability of pixel \(x_i\) given the pixels before it. \[ p(x) = \prod_{i=1}^{n^2} p(x_i \mid x_1,\dots,x_{i-1}) \]
Within each pixel the three color channels are factored in turn, so the green value is conditioned on the red value and the blue value on both. \[ p(x_i,R \mid x_{<i})\, p(x_i,G \mid x_{<i}, x_{i,R})\, p(x_i,B \mid x_{<i}, x_{i,R}, x_{i,G}) \] Each color is therefore conditioned on the other channels already produced as well as on all earlier pixels.
Each channel value is treated as one of 256 discrete categories, and each conditional is a multinomial produced by a softmax layer. Because no density family is assumed, the output can place mass on several modes or on skewed shapes, which is the property that favors it over the continuous densities used in earlier work. Training and evaluation compute these distributions for all positions in parallel, whereas generating an image has to proceed one pixel at a time.
Row LSTM and Diagonal BiLSTM layers
The Row LSTM is unidirectional and runs from top to bottom, computing the states of a whole row at once with a one-dimensional convolution. Its input-to-state part is a masked convolution with a k by 1 kernel over the full input map, so it can be computed for all positions in advance, while the state-to-state part is applied one row at a time.
With \(h_{i-1}\) and \(c_{i-1}\) the previous hidden and cell states and \(x_i\) row \(i\) of the input map, one step is: \[ [o_i, f_i, i_i, g_i] = \sigma(K_{ss} \circledast h_{i-1} + K_{is} \circledast x_i),\quad c_i = f_i \odot c_{i-1} + i_i \odot g_i,\quad h_i = o_i \odot \tanh(c_i) \] The logistic sigmoid is applied to the output, forget and input gates, and tanh to the content gate.
Because the Row LSTM's receptive field is triangular, it cannot reach the full available context.
The Diagonal BiLSTM aims to parallelize along diagonals while reaching the whole preceding context at any image size. Each of its two directions starts at one corner and sweeps toward the opposite corner, computing one diagonal per step. To make diagonals line up in memory, each row is offset by one position relative to the row above, which gives an n by (2n minus 1) map that is cut back to n by n afterwards.
Its input-to-state part is a 1 by 1 convolution, and its state-to-state part is a column-wise convolution with a 2 by 1 kernel. The output of the backward direction is moved down one row and summed with the forward output, which keeps future pixels out of the prediction. A 2 by 1 kernel keeps each step's computation small and nonlinear, and larger kernels add little because the receptive field is already global.
Residual connections, masks and the PixelCNN
Residual connections link each LSTM layer to the next, which speeds convergence and lets signals move more directly through a deep stack of up to twelve layers. The layer input has 2h features; the input-to-state part reduces them to h features per gate, a 1 by 1 convolution lifts the recurrent output back to 2h features, and the layer input is added to it.
This adds no extra gates, which distinguishes it from earlier gated approaches to depth.
The feature maps are split into three groups for the RGB channels: red sees only pixels above and to the left, green also sees red, and blue sees both red and green. Mask A is applied only to the first convolutional layer and does not allow a color to connect to itself, while mask B is applied to all later input-to-state transitions and does allow that self-connection.
The masks are implemented by zeroing the corresponding weights after each update.
The PixelCNN replaces the recurrence with standard masked convolutions, which give a bounded receptive field and compute all positions at once. Pooling is not used, so spatial resolution is kept, and the network has fifteen layers, beginning with a 7 by 7 convolution with mask A and using 3 by 3 convolutions with mask B.
Conditioning on a small image
An unconditional PixelRNN first generates a small s by s image that is subsampled from the original. A conditional PixelRNN then generates the larger n by n image, and each of its layers is biased by an upsampled version of the small image. Deconvolutional layers upsample the small image to a c by n by n map, and a 1 by 1 unmasked convolution maps that map to 4h by n by n and adds it to each layer's input-to-state map.
Model sizes and training choices
On MNIST the Diagonal BiLSTM has 7 layers with h = 16, and its output layers have 32 feature maps. On CIFAR-10 the Row and Diagonal BiLSTMs have 12 layers with h = 128, the PixelCNN has 15 layers with h = 128, and the output layers have 1024 feature maps. For 32 by 32 ImageNet a 12-layer Row LSTM with h = 384 is used, and for 64 by 64 ImageNet a 4-layer Row LSTM with h = 512 is used, without residual connections.
RMSProp gave the best convergence among the update rules tried and was used for all experiments, with learning rate schedules set by hand for each dataset. Batches had 16 images for MNIST and CIFAR-10, and 64 and 32 images for 32 by 32 and 64 by 64 ImageNet respectively. Images were only scaled and centered, and the initial recurrent state is learned.
MNIST scores are negative log-likelihoods in nats, and CIFAR-10 and ImageNet scores are in bits per dimension. The total discrete log-likelihood is normalized by the number of dimensions, which is 3072 for a 32 by 32 by 3 CIFAR-10 image.
Residual, skip and depth ablations
In a 12-layer Row LSTM on CIFAR-10 validation, residual connections without skip connections lower the value from 3.22 to 3.07 bits/dim. Skip connections alone give 3.09 without residual connections, and using both residual and skip connections gives 3.06. The authors report that residual connections are about as effective as skip connections, and that using both keeps that benefit.
With residual and skip connections, validation error falls as layers are added: 3.30 bits/dim at one layer, 3.20 at two, 3.17 at three, 3.09 at six, 3.08 at nine and 3.06 at twelve. The improvement with depth holds up to the 12 layers tested.
For the Row LSTM on CIFAR-10 validation, the softmax output gives 3.06 bits/dim. The same model with a mixture of conditional Gaussian scale mixtures gives 3.22 bits/dim, so the discrete softmax is the lower value here.
Benchmark results on MNIST, CIFAR-10 and ImageNet
On binarized MNIST the Diagonal BiLSTM with 7 layers and h = 16 reaches 79.20 nats on the test set, below the 80.54 of the Row LSTM and the 81.30 of the PixelCNN in the same table. A single-layer Diagonal BiLSTM with h = 32 reaches 80.75. The authors state that this is the best MNIST result they know of so far.
On CIFAR-10 test without data augmentation, the Diagonal BiLSTM reaches 3.00 bits/dim, the Row LSTM 3.07 and the PixelCNN 3.14. Their training values are 2.93, 3.00 and 3.08 bits/dim. The best prior entry in that table is RIDE at 3.47 bits/dim, which the table gives as a personal communication, and the uniform distribution is at 8.00. They attribute the ordering to receptive field size: the Diagonal BiLSTM sees the whole preceding context, the Row LSTM a partly occluded one, and the PixelCNN the fewest pixels.
To the authors' knowledge there are no published results on ImageNet to compare against, so the table reports only the models' own numbers. The 32 by 32 model reaches 3.86 bits/dim on validation (3.83 on training), and the 64 by 64 model reaches 3.63 bits/dim (3.57 on training). They report no overfitting, since validation performance improved with model size and depth.
Samples from the 32 by 32 ImageNet model capture more global structure than those from the CIFAR-10 model, which the authors link to its larger size and more training data.
On 64 by 64 ImageNet the multi-scale model reaches log-likelihood similar to the single-scale model, but its samples look globally more coherent on visual inspection.
Limits of sampling, scale and scope
Generation is sequential, because each sampled pixel has to be fed back into the network before the next one can be predicted, even though training and evaluation run in parallel.
The authors report that the size of the ImageNet models is currently limited by computation time and GPU memory. ImageNet images are less compressible than CIFAR-10 images, and the CIFAR-10 images were likely resized with a different algorithm, which can change compression performance.
Depth was tested only up to 12 LSTM layers, and the 64 by 64 ImageNet model uses 4 layers without residual connections. The CIFAR-10 results are without data augmentation, and the MNIST results are on the binary version of the dataset. The multi-scale benefit is judged from samples, since its log-likelihood is similar to that of the single-scale model.
Paper info
- Authors
- Aaron van den Oord, Nal Kalchbrenner, Koray Kavukcuoglu
- Venue
- arXiv · Preprint
- First published
- 2016-1-25
- Added
- 2026-11-13
- Updated
- 2016-8-19
- Version
- v3
- arXiv
- 1601.06759
- Category
- cs.CV · cs.LG · cs.NE
- 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
Aaron van den Oord, Nal Kalchbrenner, Koray Kavukcuoglu (2016). Pixel Recurrent Neural Networks. arXiv:1601.06759v3. https://arxiv.org/abs/1601.06759v3
BibTeX
@misc{oord2016pixel,
title = {{Pixel Recurrent Neural Networks}},
author = {Aaron van den Oord and Nal Kalchbrenner and Koray Kavukcuoglu},
year = {2016},
eprint = {1601.06759},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1601.06759v3}
}