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) -> BGiven data and PQ codeboks, quantize.
Arguments
X::Matrix{T}:d-by-ndata to quantizeC::Vector{Matrix{T}}:m-long vector withd/m-by-hmatrix entries. Each matrix is a PQ codebook.V::Bool: Whether to print progress
Returns
B::Matrix{Int16}:m-by-nmatrix with the codes that approximateX
Rayuela.train_pq — Function.train_pq(X, m, h, niter=25, V=false) -> C, B, errorTrains a product quantizer.
Arguments
X::Matrix{T}:d-by-ndata 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-hmatrix entries. Each matrix is a codebook of size approximatelyd/m-by-h.B::Matrix{Int16}:m-by-nmatrix 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]