arXiv:2410.06424cs.LGcs.CV2024-10ICLR被引 61

改进向量量化梯度传播,提升VAE重构质量与代码本利用率。

Restructuring Vector Quantization with the Rotation Trick

  • 用旋转缩放变换替代传统量化,实现梯度直通。
  • 在11种训练设置中降低量化误差,提升重建指标。
  • 适合研究向量量化或需精准梯度的生成模型开发者。

向量量化变分自编码器(VQ-VAEs)旨在将连续输入压缩至离散潜在空间并以最小失真重建。其通过维护一组向量(即代码本),将每个编码器输出量化为最邻近的代码本向量。然而,由于向量量化不可微,梯度在反向传播时绕过该层,采用非直通近似,导致量化操作的所有信息丢失。本文提出一种新方法,使梯度能通过向量量化层。我们通过旋转和缩放线性变换,将每个编码器输出平滑映射至对应代码本向量,并在反向传播中将其视为常数。结果,编码器输出与代码本向量之间的相对大小和角度被编码进梯度,反向传递回编码器。在11种不同的VQ-VAE训练范式中,该重构方法显著改善了重建指标、代码本利用率和量化误差。代码已开源:https://github.com/cfifty/rotation_trick。

原文摘要 · Abstract (English)

Vector Quantized Variational AutoEncoders (VQ-VAEs) are designed to compress a continuous input to a discrete latent space and reconstruct it with minimal distortion. They operate by maintaining a set of vectors -- often referred to as the codebook -- and quantizing each encoder output to the nearest vector in the codebook. However, as vector quantization is non-differentiable, the gradient to the encoder flows around the vector quantization layer rather than through it in a straight-through approximation. This approximation may be undesirable as all information from the vector quantization operation is lost. In this work, we propose a way to propagate gradients through the vector quantization layer of VQ-VAEs. We smoothly transform each encoder output into its corresponding codebook vector via a rotation and rescaling linear transformation that is treated as a constant during backpropagation. As a result, the relative magnitude and angle between encoder output and codebook vector becomes encoded into the gradient as it propagates through the vector quantization layer and back to the encoder. Across 11 different VQ-VAE training paradigms, we find this restructuring improves reconstruction metrics, codebook utilization, and quantization error. Our code is available at https://github.com/cfifty/rotation_trick.

向量量化梯度传播VAE代码本

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。