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) -> B
Given data and PQ/OPQ codeboks, quantize.
Arguments
X::Matrix{T}
:d
-by-n
data to quantizeR::Matrix{T}
:d
-by-d
rotation to apply to the data before quantizingC::Vector{Matrix{T}}
:m
-long vector withd/m
-by-h
matrix entries. Each matrix is a (O)PQ codebook.V::Bool
: Whether to print progress
Returns
B::Matrix{Int16}
:m
-by-n
matrix with the codes that approximateX
Rayuela.train_opq
โ Function.train_opq(X, m, h, niter, init, V=false) -> C, B, R, error
Trains an optimized 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 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-n
matrix with the codesC::Vector{Matrix{T}}
:m
-long vector withd
-by-h
matrix entries. Each matrix is a codebook of size approximatelyd/m
-by-h
.R::Matrix{T}
:d
-by-d
learned 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]