Enhanced residual vector quantization (ERVQ)

Enhanced residual vector quantization (ERVQ)

Enhanced residual vector quantization (ERVQ), also known as Stacked quantizers (SQ) is an non-orthogonal MCQ method.

The method is typically intialized with RVQ, and fine-tunes the codebooks to obtain a better approximation that can be quantized efficiently with quantize_rvq.

Rayuela.quantize_ervq โ€” Function.
quantize_ervq(X, C, V=false) -> B, singletons

Given data and full-dimensional codebooks, quantize. This methods is identical to quantize_rvq

Arguments

  • X::Matrix{T}: d-by-n data to quantize
  • C::Vector{Matrix{T}}: m-long vector with d-by-h matrix entries. Each matrix is a codebook.
  • V::Bool: Whether to print progress

Returns

  • B::Matrix{Int16}: m-by-n codes that approximate X
  • singletons::Vector{Matrix{T}}: m matrices with unused codebook entries
source
Rayuela.train_ervq โ€” Function.
train_ervq(X, B, C, m, h, niter, V=false) -> C, B, error

Train an enhanced residual quantizer / stacked quantizer. This method is typically initialized by Residual vector quantization (RVQ)

Arguments

  • X::Matrix{T}: d-by-n data to quantize
  • B::Matrix{T2}: m-by-n matrix with pre-trained codes
  • C::Vector{Matrix{T}}: m-long vector with d-by-h matrices. Each matrix is a pretrained codebook of size approximately d-by-h.
  • m::Integer: Number of codebooks
  • h::Integer: Number of entries in each codebook (typically 256)
  • niter::Integer: Number of iterations to use
  • V::Bool: Whether to print progress

T <: AbstractFloat and T2 <: Integer

Returns

  • C::Vector{Matrix{T}}: m-long vector with d-by-h matrix entries. Each matrix is a codebook of size approximately d-by-h.
  • B::Matrix{Int16}: m-by-n matrix with the codes
  • error::T: The quantization error after training
source

Reference

The main ideas come from

Independently, Martinez released a similar method with a some improvements and an open-source implementation: