All models

VQModel

An autoencoder that maps each encoder output to the nearest vector in a learned embedding table.

Diffusion and generative · 143 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (26 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
VQ-VAE
Parameters
560.4K
Operations
143
Framework
PyTorch
Recurrent
No
Published
2017
Cited by
4,446 (as of 18 November 2026)
Authors
Aaron van den Oord, Oriol Vinyals, Koray Kavukcuoglu
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m3312
Graph hash
afe3a2ea0fdd22c888958a575d25b95280bdc76ff024b4e9198472a19b3826d4
Skeleton hash
0be841c7635955374216e59d16dd8cec0ece220c7ebf04710629a5c388b62904
Architecture hash
cf218861bd30e7f4af44343ffada96da6322f9918843cac0e22db0572b999e5f
Diagram SHA-256
ebcfce46926b462d1871be88fe0d61051c526f2027803a3f535cbff308c31e40
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

About this model's family

VQ-VAE, the Vector Quantised-Variational AutoEncoder, is an autoencoder with a discrete bottleneck: each encoder output is replaced by its nearest entry in a shared table of embedding vectors before it reaches the decoder. The paper describes this forward pass as a regular autoencoder with one particular non-linearity that maps the latents to 1-of-K embedding vectors.

The lookup has no real gradient, so gradients are copied from the decoder input straight to the encoder output, similar to the straight-through estimator. The embedding vectors therefore receive no gradient from the reconstruction loss and are learned with a separate vector quantization term that moves them toward the encoder outputs. A third term, the commitment loss, makes sure the encoder commits to an embedding and its output does not grow.

The abstract names two differences from ordinary VAEs: the encoder outputs discrete codes instead of continuous ones, and the prior is learned instead of static. In the paper that prior is fit after training, a PixelCNN over the discrete latents for images and a WaveNet for raw audio. Used on its own, as in the MONAI tutorial, the network returns a reconstruction and the quantization error.

Key idea. The paper builds a VAE-style model whose encoder outputs discrete codes through vector quantization and pairs it with a learned autoregressive prior.

  • VQ-VAE
  • VQVAE
  • Vector Quantised-Variational AutoEncoder
  • vector quantized variational autoencoder
  • vector quantization
  • discrete latent
  • codebook
  • Neural Discrete Representation Learning
  • VQModel
  • discrete representation learning

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{oord2018neuraldiscreterepresentationlearning,
      title={Neural Discrete Representation Learning}, 
      author={Aaron van den Oord and Oriol Vinyals and Koray Kavukcuoglu},
      year={2018},
      eprint={1711.00937},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1711.00937}, 
}