
monai.VQVAE
Diffusion and generative100 ops11.7M params
An autoencoder that maps each encoder output to the nearest vector in a learned embedding table.
Diffusion and generative · 143 operations Checked
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.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
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.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@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},
}