shark::ScaledKernel< InputType > Class Template Reference

Scaled version of a kernel function. More...

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

+ Inheritance diagram for shark::ScaledKernel< 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

 ScaledKernel (AbstractKernelFunction< InputType > *base, double factor=1.0)
 
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.
 
std::size_t numberOfParameters () const
 Return the number of parameters.
 
boost::shared_ptr< StatecreateState () const
 creates the internal state of the kernel
 
const double factor ()
 
void setFactor (double f)
 
const base_typebase () const
 
double eval (ConstInputReference x1, ConstInputReference x2) const
 
void eval (ConstBatchInputReference x1, ConstBatchInputReference x2, RealMatrix &result) const
 
void eval (ConstBatchInputReference x1, ConstBatchInputReference x2, RealMatrix &result, State &state) const
 
void weightedParameterDerivative (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix const &coefficients, State const &state, RealVector &gradient) const
 calculates the weighted derivate w.r.t. the parameters of the base kernel
 
void weightedInputDerivative (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix const &coefficientsX2, State const &state, BatchInputType &gradient) const
 calculates the weighted derivate w.r.t. argument \( x_1 \)
 
void read (InArchive &ar)
 From ISerializable, reads a metric from an archive.
 
void write (OutArchive &ar) const
 The kernel does not serialize anything.
 
- 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

AbstractKernelFunction< InputType > * m_base
 kernel to scale
 
double m_factor
 scaling factor
 
- Protected Attributes inherited from shark::AbstractKernelFunction< InputTypeT >
Features m_features
 

Detailed Description

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

Scaled version of a kernel function.

For a positive definite kernel k, the scaled kernel

\[ \tilde k(x_1, x_2) := c k(x_1, x_2) \]

is again a positive definite kernel function as long as \( c > 0 \).

Definition at line 50 of file ScaledKernel.h.

Member Typedef Documentation

◆ BatchInputType

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

Definition at line 55 of file ScaledKernel.h.

◆ ConstBatchInputReference

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

Definition at line 57 of file ScaledKernel.h.

◆ ConstInputReference

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

Definition at line 56 of file ScaledKernel.h.

Constructor & Destructor Documentation

◆ ScaledKernel()

Member Function Documentation

◆ base()

◆ createState()

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

creates the internal state of the kernel

Reimplemented from shark::AbstractKernelFunction< InputTypeT >.

Definition at line 87 of file ScaledKernel.h.

References shark::AbstractKernelFunction< InputTypeT >::createState(), and shark::ScaledKernel< InputType >::m_base.

◆ eval() [1/3]

◆ eval() [2/3]

template<class InputType = RealVector>
void shark::ScaledKernel< InputType >::eval ( ConstBatchInputReference  x1,
ConstBatchInputReference  x2,
RealMatrix &  result,
State state 
) const
inline

◆ eval() [3/3]

◆ factor()

template<class InputType = RealVector>
const double shark::ScaledKernel< InputType >::factor ( )
inline

◆ name()

template<class InputType = RealVector>
std::string shark::ScaledKernel< InputType >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 72 of file ScaledKernel.h.

◆ numberOfParameters()

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

Return the number of parameters.

Reimplemented from shark::IParameterizable< VectorType >.

Definition at line 82 of file ScaledKernel.h.

References shark::ScaledKernel< InputType >::m_base, and shark::IParameterizable< VectorType >::numberOfParameters().

◆ parameterVector()

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

Return the parameter vector.

Reimplemented from shark::IParameterizable< VectorType >.

Definition at line 75 of file ScaledKernel.h.

References shark::ScaledKernel< InputType >::m_base, and shark::IParameterizable< VectorType >::parameterVector().

◆ read()

template<class InputType = RealVector>
void shark::ScaledKernel< InputType >::read ( InArchive archive)
inlinevirtual

From ISerializable, reads a metric from an archive.

Reimplemented from shark::AbstractMetric< InputTypeT >.

Definition at line 143 of file ScaledKernel.h.

References shark::ScaledKernel< InputType >::m_base, and shark::ScaledKernel< InputType >::m_factor.

◆ setFactor()

template<class InputType = RealVector>
void shark::ScaledKernel< InputType >::setFactor ( double  f)
inline

◆ setParameterVector()

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

◆ weightedInputDerivative()

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

◆ weightedParameterDerivative()

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

calculates the weighted derivate w.r.t. the parameters of the base kernel

Definition at line 119 of file ScaledKernel.h.

References shark::ScaledKernel< InputType >::m_base, shark::ScaledKernel< InputType >::m_factor, and shark::AbstractKernelFunction< InputTypeT >::weightedParameterDerivative().

◆ write()

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

The kernel does not serialize anything.

Reimplemented from shark::AbstractMetric< InputTypeT >.

Definition at line 149 of file ScaledKernel.h.

References shark::ScaledKernel< InputType >::m_factor.

Member Data Documentation

◆ m_base

◆ m_factor


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