SandHouse
Pages

VQ-VAE

A discrete variational auto encoder (see VAE). Useful when you want your latent space to be discrete (e.g. predicting discrete actions of video gameplay to label inputs in a self-supervised manner).

Your discrete latents are e1,…,eK

It’s a VAE but after you’ve sampled your latent state z, you set z to the nearest ei (kNN), then your loss is described as such:

ℒ=log⁡p(x|zq(x))+||sg[ze(x)]−e‖22+β||ze(x)−sg[e]||22

Where the first terms enforces the latent state to be decodable to the image, the second forces the chosen embedding vector to move closer to the continuous latent state, and the last forcing the latent state to stay near the embedding. usually beta is 0.25. This keeps the volume “finite” because otherwise, the continuous latent could scale and the embedding would be forced to follow.