Optimized product quantization (OPQ)
Optimized product quantization is an orthogonal MCQ method that also learns a rotation R of the data.
Rayuela.quantize_opq โ Function.quantize_opq(X, R, C, V=false) -> BGiven data and PQ/OPQ codeboks, quantize.
Arguments
X::Matrix{T}:d-by-ndata to quantizeR::Matrix{T}:d-by-drotation to apply to the data before quantizingC::Vector{Matrix{T}}:m-long vector withd/m-by-hmatrix entries. Each matrix is a (O)PQ codebook.V::Bool: Whether to print progress
Returns
B::Matrix{Int16}:m-by-nmatrix with the codes that approximateX
Rayuela.train_opq โ Function.train_opq(X, m, h, niter, init, V=false) -> C, B, R, errorTrains an optimized 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 iterations to useinit::String: Method used to intiializeR, either"natural"(identity) or"random".V::Bool: Whether to print progress
Returns
B::Matrix{Int16}:m-by-nmatrix with the codesC::Vector{Matrix{T}}:m-long vector withd-by-hmatrix entries. Each matrix is a codebook of size approximatelyd/m-by-h.R::Matrix{T}:d-by-dlearned rotation for the dataobj::Vector{T}: The quantization error each iteration
Reference
The main ideas were published at the same time by two independent groups:
- Ge, T., He, K., Ke, Q., & Sun, J. (2013). Optimized product quantization for approximate nearest neighbor search. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (pp. 2946-2953). [PDF]
- Norouzi, M., & Fleet, D. J. (2013). Cartesian k-means. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (pp. 3017-3024). [PDF]
An extended version was later publised in a computer vision journal:
- Ge, T., He, K., Ke, Q., & Sun, J. (2014). Optimized product quantization. IEEE transactions on pattern analysis and machine intelligence, 36(4), 744-755. [PDF]