VQ-VAE is a quantized ๐๏ธ Variational Autoencoder that uses discrete latent variables trained via vector quantization (VQ). We maintain a codebook containing embedding vectors
This gives us the posterior distribution:
Our quantized
Training
To train this system, we need to not only optimize the encoder and decoder but also the embedding codebookโthe embedding vectors should be set to accurately quantize the encoding. Thus, we have reconstruction loss, the VQ objective (which moves embedding vectors
where
Also, since itโs impossible to mathematically pass the decoder gradient past the quantization step to the encoder, we approximate it by simply copying the gradient over, skipping the quantization step.