Neural Discrete Representation Learning

Aaron van den Oord, Oriol Vinyals, Koray Kavukcuoglu

TL;DR

The paper introduces the Vector Quantised-Variational AutoEncoder (VQ-VAE), a generative model that learns discrete latent representations instead of continuous ones. By combining variational autoencoders with vector quantization, VQ-VAE completely avoids the common issue of "posterior collapse" and generates high-quality images, video, and speech in an entirely unsupervised manner.

What Problem Does This Paper Address?

Unsupervised representation learning aims to capture the core, high-level features of data without requiring human labels. While many real-world modalities—such as language, speech phonemes, and logical reasoning steps—are inherently discrete, most popular deep generative models (like standard VAEs) rely on continuous latent spaces.

Training VAEs with discrete latents has traditionally been notoriously difficult because you cannot backpropagate gradients through discrete choices. Furthermore, when standard VAEs are paired with powerful autoregressive decoders (like PixelCNN), they often suffer from posterior collapse. This is a failure mode where the model learns to ignore the latent variables entirely because the decoder is strong enough to model the data distribution on its own, rendering the learned representations useless.

Methods

The authors introduce VQ-VAE, which re-architects the standard VAE framework using ideas from vector quantization (VQ):

  1. Discrete Latent Bottleneck: The encoder maps an input $x$ to a continuous space $z_e(x)$. This vector is then quantized by finding its nearest neighbor in a learned dictionary of embedding vectors $e \in \mathbb{R}^{K \times D}$ (the codebook). The index of the closest codebook vector becomes the discrete latent variable $z$.
  2. Straight-Through Estimation: Because the nearest-neighbor lookup (an argmin operation) is non-differentiable, the authors use a straight-through estimator during the backward pass. The gradients from the decoder are copied directly and unaltered back to the encoder.
  3. Novel Loss Function: The total objective function contains three components:
  4. Reconstruction loss: Optimizes both the encoder and decoder to accurately recreate the input.
  5. VQ loss: Moves the chosen codebook embeddings closer to the encoder outputs.
  6. Commitment loss: Prevents the encoder outputs from fluctuating too wildly between different codebook vectors.
  7. Autoregressive Prior: Once the VQ-VAE is trained and its discrete latent space is fixed, the authors train a powerful autoregressive model (like PixelCNN for images or WaveNet for audio) over these discrete codes to serve as a learned prior for high-quality data generation.
Figure 1: Left: A figure describing the VQ-VAE. Right: Visualisation of the embedding space. The output of the encoder z(x) is mapped to the nearest point e2. The gradient ∇zL (in red) will push the encoder to change its output, which could alter the configuration in the next forward pass.

Datasets

The model was evaluated across three distinct modalities using standard benchmarks:

  • Images: CIFAR10, ImageNet (128x128), and video frames from DeepMind Lab.
  • Audio: The VCTK dataset (speech recordings of 109 different speakers) and a larger speech dataset containing 460 speakers.

No new datasets or benchmarks were introduced in this work.

Key Insights and Ideas

  • Immunity to Posterior Collapse: Because the discrete bottleneck forces the network to commit to specific codebook vectors rather than distributing probability mass continuously, the latents retain high information content. The decoder cannot easily bypass them, eliminating posterior collapse.
  • Unsupervised Feature Disentanglement: When trained on raw audio without any text transcriptions or linguistic labels, the discrete latents naturally learn to capture high-level phoneme structures. Crucially, they completely ignore speaker identity. By later conditioning the decoder on a speaker ID, the model can perform unsupervised speaker conversion—changing the voice characteristics while keeping the spoken words identical.
  • Effective Global Compression: By compressing images into a discrete grid of indices (achieving over a 40x reduction in bits), the model discards local pixel noise and focuses entirely on global structure, resulting in highly coherent reconstructions.

Key Results

  • Competitive Likelihoods: On CIFAR10, VQ-VAE achieves a negative log-likelihood of 4.67 bits/dim, which is nearly as good as its continuous VAE counterpart (4.51 bits/dim) and significantly outperforms older discrete VAE techniques like VIMCO (5.14 bits/dim).
  • High-Quality Audio Synthesis: Unconditional audio generation using the learned WaveNet prior produces clear, recognizable words and part-sentences. This is a major qualitative leap over standard unconditional WaveNets, which typically sound like unintelligible babbling.
  • Phoneme Accuracy: To validate what the discrete codes actually learned, the authors mapped the unsupervised latents to ground-truth phonemes. The model achieved a 49.3% accuracy on a 41-way classification task, vastly outperforming a random baseline of 7.2%.
Figure 3: Samples (128x128) from a VQ-VAE with a PixelCNN prior trained on ImageNet images. From left to right: kit fox, gray whale, brown bear, admiral (butterfly), coral reef, alp, microwave, pickup.

Limitations and Future Work

  • Two-Stage Training: Currently, the VQ-VAE and the autoregressive prior are trained sequentially. The authors note that learning the prior and the representation jointly remains an important open challenge that could yield even better results.
  • Blurry Reconstructions: Because the image reconstruction loss relies on Mean Squared Error (MSE) at the pixel level, the generated outputs can still appear slightly blurry. The authors suggest that incorporating a perceptual loss function, such as a GAN loss, is a promising direction for future work.

Summary updated

BibTeX
@inproceedings{oord2017neural,
  author = {Aaron van den Oord and Oriol Vinyals and Koray Kavukcuoglu},
  title = {{Neural Discrete Representation Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
  url = {https://openreview.net/forum?id=BJ-sLPZOZS},
}
Figure