Skip to content
heliaEDGE
Reference
HELIA

vector_quantizer

Machine-readable model

  • VectorQuantizerclassVector-quantization bottleneck (VQ-VAE style) with straight-through estimator.
class

Vector-quantization bottleneck (VQ-VAE style) with straight-through estimator.

helia_edge/layers/vector_quantizer.py:6

VectorQuantizer(num_embeddings, embedding_dim, beta=0.25, **kw={})

Vector-quantization bottleneck (VQ-VAE style) with straight-through estimator.

Input: […, D] (last dim == embedding_dim) Output: […, D] (quantized/dequantized vectors; gradients pass through x)

Tracks (logged automatically via metrics property):

  • vq_perplexity : effective # active codes (1..K)
  • vq_usage : fraction of codes used at least once (0..1)
  • vq_bits_per_index : entropy lower bound in bits/index (~ log2 perplexity)

Adds losses via add_loss:

  • beta * ||stop(quant) - x||^2 (commitment)
  • ||quant - stop(x)||^2 (codebook)