VQ-VAE (van den Oord et al., 2017) quantizes each encoder output to its nearest entry in a learned codebook. The latent becomes a discrete index, which the decoder maps back to a code vector.
Implement nearest_code_index(z, codebook), the index of the closest codebook row.
Compute the distances from z to every code and take the argmin.
No results yet
Run your code to check it against the examples, or submit to run every test.