shark::GaussianRbfKernel< InputType > Class Template Reference

Gaussian radial basis function kernel. More...

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

+ Inheritance diagram for shark::GaussianRbfKernel< InputType >:
+ Collaboration diagram for shark::GaussianRbfKernel< InputType >:

Public Types

typedef base_type::BatchInputType BatchInputType
 
typedef
base_type::ConstInputReference 
ConstInputReference
 
typedef
base_type::ConstBatchInputReference 
ConstBatchInputReference
 
- Public Types inherited from shark::AbstractKernelFunction< InputType >
enum  Feature
 enumerations of kernel features (flags) More...
 
typedef InputType InputType
 Input type of the Kernel. More...
 
typedef Traits::type BatchInputType
 batch input type of the kernel More...
 
typedef ConstProxyReference
< InputType const >::type 
ConstInputReference
 Const references to InputType. More...
 
typedef ConstProxyReference
< BatchInputType const >
::type 
ConstBatchInputReference
 Const references to BatchInputType. More...
 
typedef TypedFlags< FeatureFeatures
 This statement declares the member m_features. See Core/Flags.h for details. More...
 
typedef
TypedFeatureNotAvailableException
< Feature
FeatureNotAvailableException
 

Public Member Functions

 GaussianRbfKernel (double gamma=1.0, bool unconstrained=false)
 
std::string name () const
 From INameable: return the class name. More...
 
RealVector parameterVector () const
 Return the parameter vector. More...
 
void setParameterVector (RealVector const &newParameters)
 Set the parameter vector. More...
 
size_t numberOfParameters () const
 Return the number of parameters. More...
 
double gamma () const
 Get the bandwidth parameter value. More...
 
double sigma () const
 Return ``standard deviation'' of Gaussian. More...
 
void setGamma (double gamma)
 
double setSigma (double sigma) const
 Set ``standard deviation'' of Gaussian. More...
 
void read (InArchive &ar)
 From ISerializable. More...
 
void write (OutArchive &ar) const
 From ISerializable. More...
 
boost::shared_ptr< StatecreateState () const
 creates the internal state of the kernel More...
 
double eval (ConstInputReference x1, ConstInputReference x2) const
 evaluates \( k(x_1,x_2)\) More...
 
void eval (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix &result, State &state) const
 evaluates \( k(x_1,x_2)\) and computes the intermediate value More...
 
void eval (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix &result) const
 Evaluates the subset of the KernelGram matrix which is defined by X1(rows) and X2 (columns). More...
 
void weightedParameterDerivative (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix const &coefficients, State const &state, RealVector &gradient) const
 Computes the gradient of the parameters as a weighted sum over the gradient of all elements of the batch. More...
 
void weightedInputDerivative (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix const &coefficientsX2, State const &state, BatchInputType &gradient) const
 Calculates the derivative of the inputs X1 (only x1!). More...
 
- Public Member Functions inherited from shark::AbstractKernelFunction< InputType >
 AbstractKernelFunction ()
 
virtual ~AbstractKernelFunction ()
 
void configure (PropertyTree const &node)
 configure the kernel More...
 
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool hasFirstParameterDerivative () const
 
bool hasFirstInputDerivative () const
 
bool isNormalized () const
 
bool supportsVariableInputSize () const
 
double operator() (ConstInputReference x1, ConstInputReference x2) const
 Convenience operator which evaluates the kernel function. More...
 
RealMatrix operator() (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2) const
 Evaluates the subset of the KernelGram matrix which is defined by X1(rows) and X2 (columns). More...
 
virtual double featureDistanceSqr (ConstInputReference x1, ConstInputReference x2) const
 Computes the squared distance in the kernel induced feature space. More...
 
virtual RealMatrix featureDistanceSqr (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2) const
 
double featureDistance (ConstInputReference x1, ConstInputReference x2) const
 Computes the distance in the kernel induced feature space. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- Public Member Functions inherited from shark::IParameterizable
virtual ~IParameterizable ()
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor. More...
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...). More...
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...). More...
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 
- Public Member Functions inherited from shark::IConfigurable
virtual ~IConfigurable ()
 Virtual d'tor. More...
 

Protected Attributes

double m_gamma
 kernel bandwidth parameter More...
 
bool m_unconstrained
 use log storage More...
 
- Protected Attributes inherited from shark::AbstractKernelFunction< InputType >
Features m_features
 

Detailed Description

template<class InputType = RealVector>
class shark::GaussianRbfKernel< InputType >

Gaussian radial basis function kernel.

Gaussian radial basis function kernel \( k(x_1, x_2) = \exp(-\gamma \cdot \| x_1 - x_2 \|^2) \) with single bandwidth parameter \( \gamma \). Optionally, the parameter can be encoded as \( \exp(\eta) \), which allows for unconstrained optimization.

Definition at line 43 of file GaussianRbfKernel.h.

Member Typedef Documentation

template<class InputType = RealVector>
typedef base_type::BatchInputType shark::GaussianRbfKernel< InputType >::BatchInputType

Definition at line 58 of file GaussianRbfKernel.h.

Definition at line 60 of file GaussianRbfKernel.h.

template<class InputType = RealVector>
typedef base_type::ConstInputReference shark::GaussianRbfKernel< InputType >::ConstInputReference

Definition at line 59 of file GaussianRbfKernel.h.

Constructor & Destructor Documentation

Member Function Documentation

template<class InputType = RealVector>
boost::shared_ptr<State> shark::GaussianRbfKernel< InputType >::createState ( ) const
inlinevirtual

creates the internal state of the kernel

Reimplemented from shark::AbstractKernelFunction< InputType >.

Definition at line 134 of file GaussianRbfKernel.h.

template<class InputType = RealVector>
double shark::GaussianRbfKernel< InputType >::eval ( ConstInputReference  x1,
ConstInputReference  x2 
) const
inlinevirtual

evaluates \( k(x_1,x_2)\)

Gaussian radial basis function kernel

\[ k(x_1, x_2) = \exp(-\gamma \cdot \| x_1 - x_2 \|^2) \]

Reimplemented from shark::AbstractKernelFunction< InputType >.

Definition at line 142 of file GaussianRbfKernel.h.

References shark::blas::distanceSqr(), shark::GaussianRbfKernel< InputType >::m_gamma, and SIZE_CHECK.

template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::eval ( ConstBatchInputReference  batchX1,
ConstBatchInputReference  batchX2,
RealMatrix &  result,
State state 
) const
inlinevirtual

evaluates \( k(x_1,x_2)\) and computes the intermediate value

Gaussian radial basis function kernel

\[ k(x_1, x_2) = \exp(-\gamma \cdot \| x_1 - x_2 \|^2) \]

Implements shark::AbstractKernelFunction< InputType >.

Definition at line 153 of file GaussianRbfKernel.h.

References shark::blas::distanceSqr(), shark::GaussianRbfKernel< InputType >::m_gamma, shark::blas::noalias(), SIZE_CHECK, and shark::State::toState().

template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::eval ( ConstBatchInputReference  batchX1,
ConstBatchInputReference  batchX2,
RealMatrix &  result 
) const
inlinevirtual

Evaluates the subset of the KernelGram matrix which is defined by X1(rows) and X2 (columns).

The result matrix is filled in with the values result(i,j) = kernel(x1[i], x2[j]);

Reimplemented from shark::AbstractKernelFunction< InputType >.

Definition at line 168 of file GaussianRbfKernel.h.

References shark::blas::distanceSqr(), shark::GaussianRbfKernel< InputType >::m_gamma, shark::blas::noalias(), and SIZE_CHECK.

template<class InputType = RealVector>
double shark::GaussianRbfKernel< InputType >::gamma ( ) const
inline
template<class InputType = RealVector>
std::string shark::GaussianRbfKernel< InputType >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 71 of file GaussianRbfKernel.h.

template<class InputType = RealVector>
size_t shark::GaussianRbfKernel< InputType >::numberOfParameters ( ) const
inlinevirtual

Return the number of parameters.

Reimplemented from shark::IParameterizable.

Definition at line 95 of file GaussianRbfKernel.h.

template<class InputType = RealVector>
RealVector shark::GaussianRbfKernel< InputType >::parameterVector ( ) const
inlinevirtual

Return the parameter vector.

Reimplemented from shark::IParameterizable.

Definition at line 74 of file GaussianRbfKernel.h.

References shark::GaussianRbfKernel< InputType >::m_gamma, and shark::GaussianRbfKernel< InputType >::m_unconstrained.

template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::read ( InArchive ar)
inlinevirtual
template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::setGamma ( double  gamma)
inline

Set the bandwidth parameter value.

Exceptions
shark::Exceptionif gamma <= 0.

Definition at line 111 of file GaussianRbfKernel.h.

References shark::GaussianRbfKernel< InputType >::gamma(), shark::GaussianRbfKernel< InputType >::m_gamma, and SHARK_CHECK.

template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::setParameterVector ( RealVector const &  newParameters)
inlinevirtual
template<class InputType = RealVector>
double shark::GaussianRbfKernel< InputType >::setSigma ( double  sigma) const
inline

Set ``standard deviation'' of Gaussian.

Definition at line 117 of file GaussianRbfKernel.h.

References shark::GaussianRbfKernel< InputType >::m_gamma, and shark::GaussianRbfKernel< InputType >::sigma().

template<class InputType = RealVector>
double shark::GaussianRbfKernel< InputType >::sigma ( ) const
inline

Return ``standard deviation'' of Gaussian.

Definition at line 105 of file GaussianRbfKernel.h.

References shark::GaussianRbfKernel< InputType >::m_gamma.

Referenced by shark::GaussianRbfKernel< InputType >::setSigma().

template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::weightedInputDerivative ( ConstBatchInputReference  batchX1,
ConstBatchInputReference  batchX2,
RealMatrix const &  coefficientsX2,
State const &  state,
BatchInputType gradient 
) const
inlinevirtual

Calculates the derivative of the inputs X1 (only x1!).

The i-th row of the resulting matrix is a weighted sum of the form: c[i,0] * k'(x1[i], x2[0]) + c[i,1] * k'(x1[i], x2[1]) + ... + c[i,n] * k'(x1[i], x2[n]).

The default implementation throws a "not implemented" exception.

Reimplemented from shark::AbstractKernelFunction< InputType >.

Definition at line 203 of file GaussianRbfKernel.h.

References shark::GaussianRbfKernel< InputType >::m_gamma, shark::blas::noalias(), shark::blas::row(), SIZE_CHECK, and shark::State::toState().

template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::weightedParameterDerivative ( ConstBatchInputReference  batchX1,
ConstBatchInputReference  batchX2,
RealMatrix const &  coefficients,
State const &  state,
RealVector &  gradient 
) const
inlinevirtual

Computes the gradient of the parameters as a weighted sum over the gradient of all elements of the batch.

The default implementation throws a "not implemented" exception.

Reimplemented from shark::AbstractKernelFunction< InputType >.

Definition at line 174 of file GaussianRbfKernel.h.

References shark::GaussianRbfKernel< InputType >::m_gamma, shark::GaussianRbfKernel< InputType >::m_unconstrained, SIZE_CHECK, and shark::State::toState().

template<class InputType = RealVector>
void shark::GaussianRbfKernel< InputType >::write ( OutArchive ar) const
inlinevirtual

Member Data Documentation


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