homkermap.h implements the homogeneous kernel maps introduced in [vedaldi10efficient]}, [vedaldi12efficient]}. Such maps are efficient linear representations of popular kernels such as the intersection, $^2$, and Jensen-Shannon ones.
The homogeneous kernel map is implemented as an object of type VlHomogeneousKernelMap. To use thois object, first create an instance by using vl_homogeneouskernelmap_new, then use vl_homogeneouskernelmap_evaluate_d or vl_homogeneouskernelmap_evaluate_f (depdening on whether the data is double
or float
) to compute the feature map $ (x) $. When done, dispose of the object by calling vl_homogeneouskernelmap_delete.
double gamma = 1.0 ; int order = 1 ; double period = -1 ; // use default double psi [3] ; vl_size psiStride = 1 ; double x = 0.5 ; VlHomogeneousKernelMap * hom = vl_homogeneouskernelmap_new( VlHomogeneousKernelChi2, gamma, order, period, VlHomogeneousKernelMapWindowRectangular) ; vl_homogeneouskernelmap_evaluate_d(hom, psi, psiStride, x) ; vl_homogeneouskernelmap_delete(x) ;
The constructor vl_homogeneouskernelmap_new takes the kernel type kernel
(see VlHomogeneousKernelType), the homogeneity order gamma
(use one for the standard $1$-homogeneous kernels), the approximation order order
(usually order one is enough), the period period (use a negative value to use the default period), and a window type window
(use VlHomogeneousKernelMapWindowRectangular if unsure). The approximation order trades off the quality and dimensionality of the approximation. The resulting feature map $ (x) $, computed by vl_homogeneouskernelmap_evaluate_d or vl_homogeneouskernelmap_evaluate_f , is 2*order+1
dimensional.
The code pre-computes the map $ (x) $ for efficient evaluation. The table spans values of $ x $ in the range $[2^{-20}, 2^{8}) $. In particular, values smaller than $ 2^{-20} $ are treated as zeroes (which results in a null feature).
The homogeneous kernel map is a finite dimensional linear approximation of homogeneous kernels, including the intersection, $^2$, and Jensen-Shannon kernels. These kernels are frequently used in computer vision applications because they are particular suited to data in the format of histograms, which includes many common visual descriptors.
Let $x,y {R}_+$ be non-negative scalars and let $k(x,y) {R}$ be an homogeneous kernel such as the $^2$ and or the intersection ones:
For vectorial data $ {x},{y} {R}_+^d $, the homogeneous kernels is defined as an additive combination of scalar kernels $K({x},{y}) = {i=1}^d k(x_i,y_i)$.
The homogeneous kernel map of order $n$ is a vector function $(x) {R}^{2n+1}$ such that, for any choice of $x, y {R}_+$, the following approximation holds:
Given the feature map for the scalar case, the corresponding feature map $({x})$ for the vectorial case is obtained by stacking $[(x_1), , (x_n)]$. Note that the stacked feature $({x})$ has dimension $d(2n+1)$.
Using linear analysis tools (e.g. a linear support vector machine) on top of dataset that has been encoded by the homogeneous kernel map is therefore approximately equivalent to using a method based on the corresponding non-linear kernel.
Any positive (semi-)definite kernel $k(x,y)$ defined on the non-negative reals $x,y {R}_+$ can be extended to the entire real line by using the definition:
The homogeneous kernel map implements this extension by defining $(x) = {sign}(x) (|x|)$. Note that other extensions are possible, such as
where $H$ is the Heaviside function, but may result in higher dimensional feature maps.
Any (1-)homogeneous kernel $k_1(x,y)$ can be extended to a so called $$-homgeneous kernel $k_(x,y)$ by the definition
Smaller values of $$ enhance the kernel non-linearity and are sometimes beneficial in applications (see [vedaldi10efficient]}, [vedaldi12efficient]} for details).
This section discusses aspects of the homogeneous kernel map which are more technical and may be skipped. The homogeneous kernel map approximation is based on periodizing the kernel; given the kernel signature
the homogeneous kernel map is a feature map for the windowed and periodized kernel whose signature is given by
where $W()$ is a windowing function and $$ is the period. This implementation of the homogeneous kernel map supports the use of a uniform window ($ W() = 1 $) or of a rectangular window ($ W() = {rect}(/) $). Note that $ = (y/x) $ is equal to the logarithmic ratio of the arguments of the kernel. Empirically, the rectangular window seems to have a slight edge in applications.
This implementation uses the expressions given in [vedaldi10efficient]}, [vedaldi11efficient]} to compute in closed form the maps $(x)$ for the supported kernel types. For efficiency reasons, it precomputes $(x)$ for a large range of values of the argument when the homogeneous kernel map object is created.
The internal table stores $(x) {R}^{2n+1}$ by sampling $x 0$. This uses the internal decomposition of IEEE floating point representations (float
and double
) in mantissa and exponent:
x = mantissa * (2**exponent), minExponent <= exponent <= maxExponent, 1 <= matnissa < 2.
Each octave is further sampled in numSubdivisions
sublevels.
When the map $(x)$ is evaluated, x
is decomposed again into exponent and mantissa to index the table. The output is obtained by bilinear interpolation from the appropriate table entries.