Residual vector quantization (RVQ)

Residual vector quantization (RVQ)

Residual vector quantization (RVQ) is an non-orthogonal MCQ method.

RVQ iteratively runs $k$-means to learn full-dimensional codebooks

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

Given data and full-dimensional codebooks, quantize.

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_rvq โ€” Function.
train_rvq(X, m, h, niter=25, V=false) -> C, B, error

Train a residual quantizer.

Arguments

  • X::Matrix{T}: d-by-n data to quantize
  • 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

Returns

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

Reference

Chen, Y., Guan, T., & Wang, C. (2010). Approximate nearest neighbor search by residual vector quantization. Sensors, 10(12), 11259-11273. [PDF]