PixelSNAIL Architecture
- PixelSNAIL is an autoregressive generative model that employs a raster-scan causal factorization to model pixel dependencies in images.
- It interleaves dilated causal convolutions with self-attention and gated residual blocks to effectively capture both local and global spatial patterns.
- The architecture achieves state-of-the-art log-likelihoods on benchmarks like CIFAR-10 and ImageNet 32×32, demonstrating improved density estimation performance.
PixelSNAIL is an autoregressive generative model architecture designed for high-dimensional data such as images, where it models the joint distribution over all input pixels using a raster-scan causal factorization. It advances previous approaches by interleaving causal convolutions with self-attention modules, while leveraging gated residual blocks, positional embeddings, and normalization to improve upon the density estimation performance of models such as PixelCNN. PixelSNAIL attains state-of-the-art log-likelihoods on benchmarks including CIFAR-10 and ImageNet 32×32 images, substantiating the efficacy of its hybrid design principles (Chen et al., 2017).
1. Autoregressive Factorization and Causal Structure
PixelSNAIL models joint distributions over all pixels , where , using a raster-scan autoregressive factorization:
Each conditional is estimated through a deep network that constructs a large receptive field over the context via a stack of components:
- Causal (masked) convolutions with increasing dilation for local-to-global dependency coverage,
- Gated residual blocks for stabilization and expressive nonlinearity,
- Interleaved self-attention modules to directly capture long-range dependencies in the spatial grid.
This structured approach overcomes limitations of conventional RNN or basic convolutional factorization, allowing efficient and powerful modeling of local and global spatial patterns (Chen et al., 2017).
2. Core Architectural Components
A. Causal Convolutional Layers
Causal convolutions use a filter, masked so that the convolution never accesses "future" pixels. Dilation is applied in powers of two (e.g., ). Stacking such layers with dilations yields a receptive field of 0 per spatial axis. For six layers with the aforementioned dilations, the receptive field covers 1 pixels, which exceeds the full spatial extent for 2 images.
B. Gated Residual Blocks
The gated block processes input 3:
- Applies a masked convolution producing 4 channels, split as 5:
6
- Computes the gated linear unit (GLU):
7
where 8 denotes the sigmoid.
- Adds residual skip connection and (optionally) applies layer normalization:
9
C. Self-Attention Modules
Self-attention is periodically applied throughout the stack:
- The reshaped state 0 is linearly projected to queries 1, keys 2, and values 3.
- Causal attention is enforced by applying a mask 4 that prevents index 5 from attending to 6:
7
- The output is reshaped and combined with the residual, followed by layer normalization. Multi-head attention is typically applied with 8 or 9 heads.
D. Pixel-Coordinate Embeddings
For spatial awareness, fixed or learned row and column embeddings 0 are added to the feature map before processing. This mechanism supports the model's ability to distinguish different locations, mitigating confusion between spatially distant but semantically distinct regions.
3. Network Shape, Channelization, and Flow
PixelSNAIL for 1 images typically operates as follows:
- Inputs are one-hot encoded (2).
- Embedding via masked 3 convolution to 4 channels: 5.
- 6 residual blocks are stacked, with 7 attention modules interleaved, without modifying spatial or channel dimensions.
- The output is projected via a masked 8 convolution to logits per-pixel and per-channel, yielding 9 logits. This represents the distribution over possible intensity values in each channel.
As the stack grows to cover the entire spatial field (e.g., 0 dilated layers for 1), each pixel’s conditional distribution leverages the full context of preceding pixels.
4. Normalization and Stabilization
Each residual block—whether convolutional or attential—applies LayerNorm after the GLU, ensuring stable activations throughout the deep stack. Weight normalization is applied (in the style of Salimans & Kingma, 2016) to convolutional filters and Q/K/V projections. This approach accelerates convergence and partially protects against gradient-related instabilities in deep, recurrently unrolled autoregressive models (Chen et al., 2017).
5. Computational Considerations and Parallelization
Causal convolutions are fully parallelizable over the spatial grid, running at 2 per layer, where 3 for 4 filters. Causal masking modifies only the convolution kernel support. Self-attention incurs 5 time and memory per module; for 6 images, this is 7. To manage the quadratic scaling, only a few attention blocks are typically inserted.
A summary of per-layer complexities:
| Component | Complexity per Layer | Typical Use |
|---|---|---|
| Causal conv | 8 | Many |
| Self-attention | 9 | Few blocks |
| 1×1 conv (embed,f) | 0 | Begin/end |
6. Empirical Results and Design Ablations
On CIFAR-10 (1), PixelSNAIL achieves bit-per-dimension scores in the range 2–3, surpassing strong PixelCNN baselines (≈4 bpd). On ImageNet 5, results around 6 bpd are reported.
Ablation studies detail the importance of architectural features:
- Removing self-attention increases CIFAR-10 bpd by approximately 7–8.
- Reducing kernel size from 9 to 0 increases bpd by around 1.
- Omitting weight normalization results in slower convergence and a degraded bpd by about 2.
Interleaving dilated convolution (rapidly expanding receptive fields) with full-image self-attention grants PixelSNAIL efficient local and global context modeling. The stabilization mechanisms (gated residuals, coordinate embeddings, normalization) collectively yield robust training dynamics and improved likelihood estimation, underpinning PixelSNAIL's state-of-the-art performance on small images (Chen et al., 2017).