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 quantizeC::Vector{Matrix{T}}
:m
-long vector withd
-by-h
matrix entries. Each matrix is a codebook.V::Bool
: Whether to print progress
Returns
B::Matrix{Int16}
:m
-by-n
codes that approximateX
singletons::Vector{Matrix{T}}
:m
matrices with unused codebook entries
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 quantizem::Integer
: Number of codebooksh::Integer
: Number of entries in each codebook (typically 256)niter::Integer
: Number of iterations to useV::Bool
: Whether to print progress
Returns
C::Vector{Matrix{T}}
:m
-long vector withd
-by-h
matrix entries. Each matrix is a codebook of size approximatelyd/m
-by-h
.B::Matrix{Int16}
:m
-by-n
matrix with the codeserror::T
: The quantization error after training
Reference
Chen, Y., Guan, T., & Wang, C. (2010). Approximate nearest neighbor search by residual vector quantization. Sensors, 10(12), 11259-11273. [PDF]