QuantizedArrays.QuantizedArrays
QuantizedArrays.AbstractQuantization
QuantizedArrays.ArrayQuantizer
QuantizedArrays.CodeBook
QuantizedArrays.QuantizedArray
QuantizedArrays.build_codebooks
QuantizedArrays.build_quantizer
QuantizedArrays.codebooks
QuantizedArrays.decode
QuantizedArrays.encode
QuantizedArrays.nvars
QuantizedArrays.opq_codebooks
QuantizedArrays.pq_codebooks
QuantizedArrays.quantization_type
QuantizedArrays.quantize
QuantizedArrays.quantize
QuantizedArrays.quantize_data
QuantizedArrays.quantized_eltype
QuantizedArrays.quantizer
QuantizedArrays.rowrange
QuantizedArrays.rvq_codebooks
QuantizedArrays.sampling_codebooks
QuantizedArrays.QuantizedArrays
— Module.QuantizedArrays.jl - array quantization and compression.
QuantizedArrays.ArrayQuantizer
— Type.ArrayQuantizer{Q,U,D,T,N}
The array quantizer object. It transforms an array with elements of type T
into a 'quantized' version with elemetns of type U
.
Fields
quantization::Q
type of quantization employed i.e. additive, orthogonaldims::NTuple{N,Int}
the original array dimensionalitycodebooks::Vector{CodeBook{U,T}}
the codebooksk::Int
the number of vector prototypes in each codebooksdistance::D
the distance employedrot::Matrix{T}
rotation matrix
QuantizedArrays.CodeBook
— Type.CodeBook{U<:Unsigned,T}
The codebook structure. It holds the codes corresponding to the vector prototypes and the mapping bethween the codes and prototypes.
Fields
codes::Vector{U}
the codesvectors::Matrix{T}
the prototypescodemap::Dict{U,Int}
mapping from code to column invectors
QuantizedArrays.QuantizedArray
— Type.QuantizedArray{Q<:AbstractQuantization,U<:Unsigned,D<:PreMetric,T,N} <: AbstractArray{T,N}
A quantized array. It represents a 'quantized' representation of an original array, equivalent to a lossy compressed version.
Fields
quantizer::ArrayQuantizer{Q,U,D,T,N}
the quantized of the arraydata::Matrix{U}
the actual compressed representation of the quantized array
QuantizedArrays.build_codebooks
— Method.build_codebooks(X, k, m, U [;method=DEFAULT_METHOD, distance=DEFAULT_DISTANCE, kwargs])
Generates m
codebooks of k
prototypes each for the input matrix X
using the algorithm specified my method
and distance distance
. Specific codebook aglorithm keyword arguments can be specified as well.
Arguments
X::AbstractMatrix{T}
input matrix of typeT
k::Int
number of prototypes/codebookm::Int
number of codebooksU::Type{<:Unsigned}
type for codebook codes
Keyword arguments
method::Symbol
the algorithm to be employed for codebook
generation; possible values are :sample
(default), :pq
for classical k-means clustering codebooks and :opq
for 'cartesian' k-means clustering codebooks
distance::PreMetric
the distance to be used in the
codebook generation methods and data encoding
kwargs...
other codebook generation algorithm specific
keyword arguments such as maxiter::Int
.
QuantizedArrays.build_quantizer
— Method.build_quantizer(aa [;kwargs])
Builds an array quantizer using the input array aa
.
Keyword arguments
k::Int
the number of vector prototypes in each codebookm::Int
the number of codebooksmethod::Symbol
the algorithm to be employed for codebook
generation; possible values are :sample
(default), :pq
for classical k-means clustering codebooks and :opq
for 'cartesian' k-means clustering codebooks
distance::PreMetric
the distance to be used in the
codebook generation methods and data encoding
Other codebook generation algorithm specific keyword arguments such as maxiter::Int
can be specified as well.
QuantizedArrays.quantize
— Method.quantize(aa; [;kwargs])
Quantize an array aa
.
Arguments
aa::AbstractArray
input array to be quantized
Keyword arguments
k::Int
the number of vector prototypes in each codebookm::Int
the number of codebooksmethod::Symbol
the algorithm to be employed for codebook
generation; possible values are :sample
(default), :pq
for classical k-means clustering codebooks and :opq
for 'cartesian' k-means clustering codebooks
distance::PreMetric
the distance to be used in the
codebook generation methods and data encoding
Other codebook generation algorithm specific keyword arguments such as maxiter::Int
can be specified as well.
QuantizedArrays.quantize
— Method.quantize(aq, aa)
Quantize an array aa
using an array quantizer aq
.
Abstract quantization type. Its subtypes are two singletons
corresponding to additive/residual and orthogonal quantization.
QuantizedArrays.codebooks
— Method.codebooks(aq)
Access the codebooks field of the array quantizer aq
.
QuantizedArrays.decode
— Method.decode(codebook, codes)
Returns a partial array reconstruction for using the codes
and codebook
.
QuantizedArrays.encode
— Method.encode(codebook, aa [;distance=DEFAULT_DISTANCE])
Encodes the input array aa using distance
to calculate the closest vector prototype from the codebook
.
QuantizedArrays.nvars
— Method.nvars(aa)
Returns the number of variables of an array aa
. For vectors, the value is always 1
, for matrices it is the number of rows in the matrix.
QuantizedArrays.opq_codebooks
— Method.opq_codebooks(X, k, m [;distance=DEFAULT_DISTANCE, maxiter=DEFAULT_PQ_MAXITER])
Build m
codebooks for input matrix X
using k
sub-space centers obtained using 'cartesian' k-means clustering, the distance distance
and maxiter
iterations.
References:
QuantizedArrays.pq_codebooks
— Method.pq_codebooks(X, k, m [;distance=DEFAULT_DISTANCE, maxiter=DEFAULT_PQ_MAXITER])
Build m
codebooks for input matrix X
using k
sub-space centers obtained using k-means clustering, the distance distance
and maxiter
iterations.
References:
QuantizedArrays.quantization_type
— Method.quantization_type(method)
Returns a quantization type based on the quantization method to be employed.
QuantizedArrays.quantize_data
— Method.quantize_data(aq, aa)
Returns a quantized version of the array aa
using the array quantizer aq
.
QuantizedArrays.quantized_eltype
— Method.quantized_eltype(k)
Determinies the minimum Unsigned
type that can hold the value k
.
QuantizedArrays.quantizer
— Method.quantizer(qa)
Access the quantizer field of a quantized array qa
.
QuantizedArrays.rowrange
— Method.rowrange(n, m, i)
Utility function that returns a range based on an iteration index i
, the number of elements n
and number of ranges m
.
QuantizedArrays.rvq_codebooks
— Method.rvq_codebooks(X, k, m [;distance=DEFAULT_DISTANCE, maxiter=DEFAULT_RVQ_MAXITER])
Build m
codebooks for input matrix X
using k
layers of residual vector cluster centers, obtained using k-means clustering, the distance distance
and maxiter
iterations.
References:
QuantizedArrays.sampling_codebooks
— Method.sampling_codebooks(X, k, m)
Build m
codebooks for input matrix X
by sampling k
prototype vectors.