GaussianTaskKernel< InputTypeT > Class Template Reference

Special "Gaussian-like" kernel function on tasks. More...

#include <shark/Models/Kernels/MultiTaskKernel.h>

+ Inheritance diagram for GaussianTaskKernel< InputTypeT >:

Public Types

typedef InputTypeT InputType
 
typedef MultiTaskSample< InputTypeMultiTaskSampleType
 
typedef AbstractKernelFunction< InputTypeKernelType
 

Public Member Functions

 GaussianTaskKernel (Data< MultiTaskSampleType > const &data, std::size_t tasks, KernelType &inputkernel, double gamma)
 Construction of a Gaussian kernel on tasks. More...
 
std::string name () const
 From INameable: return the class name. More...
 
RealVector parameterVector () const
 
void setParameterVector (RealVector const &newParameters)
 
std::size_t numberOfParameters () const
 
std::size_t numberOfTasks () const
 
double gamma () const
 Kernel bandwidth parameter. More...
 
double sigma () const
 Kernel width parameter, equivalent to the bandwidth parameter. More...
 
void setGamma (double gamma)
 
void setWidth (double sigma)
 Set the kernel width (equivalent to setting the bandwidth). More...
 
void read (InArchive &ar)
 From ISerializable. More...
 
void write (OutArchive &ar) const
 From ISerializable. More...
 

Protected Member Functions

void computeMatrix ()
 Compute the Gram matrix of the task kernel. More...
 

Protected Attributes

Data< MultiTaskSampleType > const & m_data
 multi-task data More...
 
KernelTypempe_inputKernel
 kernel on inputs More...
 
double m_gamma
 bandwidth of the Gaussian task kernel More...
 

Detailed Description

template<class InputTypeT>
class GaussianTaskKernel< InputTypeT >

Special "Gaussian-like" kernel function on tasks.

See
Learning Marginal Predictors: Transfer to an Unlabeled Task. G. Blanchard, G. Lee, C. Scott.
This class computes a Gaussian kernel based on the distance of empirical distributions in feature space induced by yet another kernel. This is useful for multi-task and transfer learning. It reduces the definition of a kernel on tasks to that of a kernel on inputs, plus a single bandwidth parameter for the Gaussian kernel of distributions.
Given unlabaled data \( x_i, t_i \) where the x-component is an input and the t-component is a task index, the kernel on tasks t and t' is defined as

\[ k(t, t') = \exp \left( -\gamma \cdot \left\| \frac{1}{\ell_{t}\ell{t'}} \sum_{i | t_i = t}\sum_{j | t_j = t'} k'(x_i, x_j) \right\|^2 \right) \]

where k' is an arbitrary kernel on inputs.

Definition at line 129 of file MultiTaskKernel.h.

Member Typedef Documentation

◆ InputType

template<class InputTypeT>
typedef InputTypeT GaussianTaskKernel< InputTypeT >::InputType

Definition at line 134 of file MultiTaskKernel.h.

◆ KernelType

template<class InputTypeT>
typedef AbstractKernelFunction<InputType> GaussianTaskKernel< InputTypeT >::KernelType

Definition at line 136 of file MultiTaskKernel.h.

◆ MultiTaskSampleType

template<class InputTypeT>
typedef MultiTaskSample<InputType> GaussianTaskKernel< InputTypeT >::MultiTaskSampleType

Definition at line 135 of file MultiTaskKernel.h.

Constructor & Destructor Documentation

◆ GaussianTaskKernel()

template<class InputTypeT>
GaussianTaskKernel< InputTypeT >::GaussianTaskKernel ( Data< MultiTaskSampleType > const &  data,
std::size_t  tasks,
KernelType inputkernel,
double  gamma 
)
inline

Construction of a Gaussian kernel on tasks.

Parameters
dataunlabeled data from multiple tasks
tasksnumber of tasks in the problem
inputkernelkernel on inputs based on which task similarity is defined
gammaGaussian bandwidth parameter (also refer to the member functions setGamma and setSigma).

Definition at line 144 of file MultiTaskKernel.h.

Member Function Documentation

◆ computeMatrix()

template<class InputTypeT>
void GaussianTaskKernel< InputTypeT >::computeMatrix ( )
inlineprotected

Compute the Gram matrix of the task kernel.

Here is the real meat. This function implements the kernel function defined in
Learning Marginal Predictors: Transfer to an Unlabeled Task. G. Blanchard, G. Lee, C. Scott.
In a first step the function computes the inner products of the task-wise empirical distributions, represented by their mean elements in the kernel-induced feature space. In a second step this information is used for the computation of squared distances between empirical distribution, which allows for the straightforward computation of a Gaussian kernel.

Definition at line 236 of file MultiTaskKernel.h.

◆ gamma()

template<class InputTypeT>
double GaussianTaskKernel< InputTypeT >::gamma ( ) const
inline

Kernel bandwidth parameter.

Definition at line 179 of file MultiTaskKernel.h.

◆ name()

template<class InputTypeT>
std::string GaussianTaskKernel< InputTypeT >::name ( ) const
inline

From INameable: return the class name.

Definition at line 157 of file MultiTaskKernel.h.

◆ numberOfParameters()

template<class InputTypeT>
std::size_t GaussianTaskKernel< InputTypeT >::numberOfParameters ( ) const
inline

Definition at line 171 of file MultiTaskKernel.h.

◆ numberOfTasks()

template<class InputTypeT>
std::size_t GaussianTaskKernel< InputTypeT >::numberOfTasks ( ) const
inline

Definition at line 175 of file MultiTaskKernel.h.

◆ parameterVector()

template<class InputTypeT>
RealVector GaussianTaskKernel< InputTypeT >::parameterVector ( ) const
inline

Definition at line 160 of file MultiTaskKernel.h.

◆ read()

template<class InputTypeT>
void GaussianTaskKernel< InputTypeT >::read ( InArchive &  ar)
inline

From ISerializable.

Definition at line 205 of file MultiTaskKernel.h.

◆ setGamma()

template<class InputTypeT>
void GaussianTaskKernel< InputTypeT >::setGamma ( double  gamma)
inline

Definition at line 189 of file MultiTaskKernel.h.

References SHARK_ASSERT.

◆ setParameterVector()

template<class InputTypeT>
void GaussianTaskKernel< InputTypeT >::setParameterVector ( RealVector const &  newParameters)
inline

Definition at line 164 of file MultiTaskKernel.h.

References remora::subrange().

◆ setWidth()

template<class InputTypeT>
void GaussianTaskKernel< InputTypeT >::setWidth ( double  sigma)
inline

Set the kernel width (equivalent to setting the bandwidth).

The bandwidth gamma and the width sigma are connected: \( gamma = 1 / (2 \cdot sigma^2) \).

Definition at line 198 of file MultiTaskKernel.h.

References SHARK_ASSERT.

◆ sigma()

template<class InputTypeT>
double GaussianTaskKernel< InputTypeT >::sigma ( ) const
inline

Kernel width parameter, equivalent to the bandwidth parameter.

The bandwidth gamma and the width sigma are connected: \( gamma = 1 / (2 \cdot sigma^2) \).

Definition at line 185 of file MultiTaskKernel.h.

◆ write()

template<class InputTypeT>
void GaussianTaskKernel< InputTypeT >::write ( OutArchive &  ar) const
inline

From ISerializable.

Definition at line 212 of file MultiTaskKernel.h.

Member Data Documentation

◆ m_data

template<class InputTypeT>
Data<MultiTaskSampleType > const& GaussianTaskKernel< InputTypeT >::m_data
protected

multi-task data

Definition at line 281 of file MultiTaskKernel.h.

◆ m_gamma

template<class InputTypeT>
double GaussianTaskKernel< InputTypeT >::m_gamma
protected

bandwidth of the Gaussian task kernel

Definition at line 283 of file MultiTaskKernel.h.

◆ mpe_inputKernel

template<class InputTypeT>
KernelType* GaussianTaskKernel< InputTypeT >::mpe_inputKernel
protected

kernel on inputs

Definition at line 282 of file MultiTaskKernel.h.


The documentation for this class was generated from the following file: