shark::GaussianRbfKernel< InputType > Class Template Reference

Gaussian radial basis function kernel. More...

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

+ Inheritance 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< InputTypeT >
enum  Feature { HAS_FIRST_PARAMETER_DERIVATIVE = 1 , HAS_FIRST_INPUT_DERIVATIVE = 2 , IS_NORMALIZED = 4 , SUPPORTS_VARIABLE_INPUT_SIZE = 8 }
 enumerations of kerneland metric features (flags) More...
 
typedef base_type::InputType InputType
 Input type of the Kernel.
 
typedef base_type::BatchInputType BatchInputType
 batch input type of the kernel
 
typedef base_type::ConstInputReference ConstInputReference
 Const references to InputType.
 
typedef base_type::ConstBatchInputReference ConstBatchInputReference
 Const references to BatchInputType.
 
typedef TypedFlags< FeatureFeatures
 This statement declares the member m_features. See Core/Flags.h for details.
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 
- Public Types inherited from shark::AbstractMetric< InputTypeT >
typedef InputTypeT InputType
 Input type of the Kernel.
 
typedef Batch< InputTypeT >::type BatchInputType
 batch input type of the kernel
 
typedef ConstProxyReference< InputTypeconst >::type ConstInputReference
 Const references to InputType.
 
typedef ConstProxyReference< BatchInputTypeconst >::type ConstBatchInputReference
 Const references to BatchInputType.
 
- Public Types inherited from shark::IParameterizable< VectorType >
typedef VectorType ParameterVectorType
 

Public Member Functions

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

Protected Attributes

double m_gamma
 kernel bandwidth parameter
 
bool m_unconstrained
 use log storage
 
- Protected Attributes inherited from shark::AbstractKernelFunction< InputTypeT >
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 51 of file GaussianRbfKernel.h.

Member Typedef Documentation

◆ BatchInputType

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

Definition at line 66 of file GaussianRbfKernel.h.

◆ ConstBatchInputReference

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

Definition at line 68 of file GaussianRbfKernel.h.

◆ ConstInputReference

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

Definition at line 67 of file GaussianRbfKernel.h.

Constructor & Destructor Documentation

◆ GaussianRbfKernel()

Member Function Documentation

◆ createState()

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< InputTypeT >.

Definition at line 142 of file GaussianRbfKernel.h.

◆ eval() [1/3]

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

◆ eval() [2/3]

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

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) \]

Definition at line 161 of file GaussianRbfKernel.h.

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

◆ eval() [3/3]

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

evaluates \( k(x_1,x_2)\)

Gaussian radial basis function kernel

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

Definition at line 150 of file GaussianRbfKernel.h.

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

◆ gamma()

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

◆ name()

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 79 of file GaussianRbfKernel.h.

◆ numberOfParameters()

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

Return the number of parameters.

Reimplemented from shark::IParameterizable< VectorType >.

Definition at line 103 of file GaussianRbfKernel.h.

◆ parameterVector()

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

◆ read()

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

◆ setGamma()

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 119 of file GaussianRbfKernel.h.

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

◆ setParameterVector()

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

◆ setSigma()

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

Set `‘standard deviation’' of Gaussian.

Definition at line 125 of file GaussianRbfKernel.h.

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

◆ sigma()

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

Return `‘standard deviation’' of Gaussian.

Definition at line 113 of file GaussianRbfKernel.h.

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

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

◆ weightedInputDerivative()

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

◆ weightedParameterDerivative()

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

◆ write()

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

Member Data Documentation

◆ m_gamma

◆ m_unconstrained


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