Introduction
Generating high-quality, high-resolution images is a massive computational challenge. Historically, likelihood-based generative models—which explicitly model the probability distribution of pixels—have relied on two main architectures: Recurrent Neural Networks (RNNs) and Convolutional Neural Networks (CNNs). While Generative Adversarial Networks (GANs) produce sharp images, they lack a tractable likelihood, making them notoriously unstable to train and prone to mode collapse.
The "Image Transformer" successfully adapts the Transformer architecture, originally designed for natural language processing, to autoregressive image generation. By restricting the self-attention mechanism to local neighborhoods, the model maintains computationally tractable memory usage while achieving significantly larger receptive fields than typical CNNs.
The Limitations of Prior Approaches
Before the Image Transformer, researchers faced a strict trade-off between receptive field size and computational efficiency:
- RNNs (e.g., PixelRNN): These models have a virtually unlimited receptive field, allowing them to model long-range dependencies like symmetry. However, they process pixels sequentially, making them painfully slow to train.
- CNNs (e.g., PixelCNN): These are highly parallelizable and faster to train, but they have a limited receptive field. Capturing long-range dependencies requires adding many layers or larger filters, which heavily bloats the parameter count.
The authors asked a pivotal question: Can we use the self-attention mechanism of the Transformer to get the best of both worlds—the parallelizability of CNNs, the large receptive field of RNNs, and the stable, tractable likelihood of autoregressive models?
Methods: Local Self-Attention
The paper treats image generation as an autoregressive sequence modeling problem: predicting the next pixel (and its color channels) given all previously generated pixels.
The core innovation is Local Self-Attention. Standard self-attention compares every token to every other token, resulting in $O(N^2)$ complexity. For a 32x32 image with 3 color channels, that is over 3,000 positions—far too computationally expensive for standard Transformers. To resolve this, the authors restrict attention to local neighborhoods using two schemes:
- 1D Local Attention: The image is flattened into a 1D sequence in raster-scan order. The model generates pixels in chunks ("query blocks"), attending only to a specific memory block of recently generated pixels.
- 2D Local Attention: The image is processed in 2D rectangular blocks. This allows the model to balance its context, looking at pixels both to the left and directly above the target pixel, rather than just a long string of preceding pixels. As images get larger, 1D flattened attention becomes heavily biased toward pixels immediately preceding the target; 2D local attention solves this by explicitly preserving spatial geometry.
The model is trained using maximum likelihood, predicting pixel intensities using either a simple categorical distribution or a Discretized Mixture of Logistics (DMOL), which better captures the ordinal nature of pixel colors with fewer parameters.
Key Results and Super-Resolution Breakthrough
The Image Transformer demonstrates that self-attention can capture spatial dependencies and texture just as well as, if not better than, convolutions. Crucially, it decouples the receptive field from the parameter count. In a CNN, increasing the receptive field adds parameters. In the Image Transformer, the receptive field is determined by the size of the memory block in the attention mechanism, allowing for massive receptive fields without inflating the model's size.
The model was evaluated across several datasets (CIFAR-10, ImageNet, and CelebA) and achieved impressive results:
- State-of-the-Art on ImageNet: The model achieved a new best negative log-likelihood (NLL) of 3.77 bits/dim on ImageNet, improving upon the previous best of 3.83.
- Competitive on CIFAR-10: It achieved 2.90 bits/dim, matching the highly optimized PixelCNN++ and outperforming standard PixelCNN.
The most striking visual results came from super-resolution tasks. When upscaling 8x8 pixel images to 32x32 on the CelebA dataset, the model generated highly plausible details—such as hair texture and makeup—that were entirely missing from the low-resolution inputs. In human evaluations, the 2D local attention model fooled human observers 36.11% of the time, more than triple the rate of the previous state-of-the-art (PixelRecursive, which scored 11.0%).
Limitations and Future Work
While local attention solves the $O(N^2)$ bottleneck of global attention, the model remains computationally heavy and memory-intensive compared to standard CNNs. Furthermore, autoregressive generation during inference (generating pixel-by-pixel) is inherently slower than single-pass generative models like GANs or VAEs.
Despite these limitations, the Image Transformer opens several exciting directions for future work, including conditioning image generation on free-form text (text-to-image synthesis), language-driven editing of existing images, and moving beyond still images to video generation.
Summary updated