Caching

Caching is an important feature of KeLP. In most of the cases, kernel computation between two examples are useful in different step of the learning process. If one caches this computation, the learning algorithm can be quicker, as computation already done can be accessed directly from a cache.

For this reason, KeLP implements two types of caching. One is the norm cache, that is useful to cache the values of the norm in the kernel space. The other is a kernel cache, that is the storage of the kernel computations.

In the following snippet, an example on how to use these two caches is provided. It refers to the Tree Kernels dataset.

There are some general guidelines when using caches in KeLP.
When using kernel combination, the kernel cache is useful only on the outer kernels, that is the combination.
Norm cache are useful only when the norm in the kernel space is necessary. There are two cases when the norm cache can be beneficial. The first is when using a RBF kernel.
The other case is when one wants to normalize a kernel function, that is when using a NormalizationKernel. In this case, the norm cache must be assigned to the inner kernel of a NormalizationKernel, as reported in the previous snippet.