Product quantization (PQ)
Product quantization is an orthogonal MCQ method that uses $k$-means as its main subroutine.
Rayuela.quantize_pq
— Function.quantize_pq(X, C, V=false) -> B
Given data and PQ codeboks, quantize.
Arguments
X::Matrix{T}
:d
-by-n
data to quantizeC::Vector{Matrix{T}}
:m
-long vector withd/m
-by-h
matrix entries. Each matrix is a PQ codebook.V::Bool
: Whether to print progress
Returns
B::Matrix{Int16}
:m
-by-n
matrix with the codes that approximateX
Rayuela.train_pq
— Function.train_pq(X, m, h, niter=25, V=false) -> C, B, error
Trains a product 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 k-means 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
Jégou, H., Douze, M., & Schmid, C. (2011). Product quantization for nearest neighbor search. IEEE transactions on pattern analysis and machine intelligence, 33(1), 117-128. [PDF]