Scaled version of a kernel function. More...
#include <shark/Models/Kernels/ScaledKernel.h>
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 kerneland metric features (flags) More... | |
typedef base_type::InputType | InputType |
Input type of the Kernel. More... | |
typedef base_type::BatchInputType | BatchInputType |
batch input type of the kernel More... | |
typedef base_type::ConstInputReference | ConstInputReference |
Const references to InputType. More... | |
typedef base_type::ConstBatchInputReference | ConstBatchInputReference |
Const references to BatchInputType. More... | |
typedef TypedFlags< Feature > | Features |
This statement declares the member m_features. See Core/Flags.h for details. More... | |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Types inherited from shark::AbstractMetric< InputType > | |
typedef InputType | InputType |
Input type of the Kernel. More... | |
typedef Batch< InputType >::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... | |
Public Types inherited from shark::IParameterizable<> | |
typedef RealVector | ParameterVectorType |
Public Member Functions | |
ScaledKernel (AbstractKernelFunction< InputType > *base, double factor=1.0) | |
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... | |
std::size_t | numberOfParameters () const |
Return the number of parameters. More... | |
boost::shared_ptr< State > | createState () const |
creates the internal state of the kernel More... | |
const double | factor () |
void | setFactor (double f) |
const base_type * | base () const |
double | eval (ConstInputReference x1, ConstInputReference x2) const |
Evaluates the kernel function. More... | |
void | eval (ConstBatchInputReference x1, ConstBatchInputReference x2, RealMatrix &result) const |
Evaluates the subset of the KernelGram matrix which is defined by X1(rows) and X2 (columns). More... | |
void | eval (ConstBatchInputReference x1, ConstBatchInputReference x2, RealMatrix &result, State &state) 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 |
calculates the weighted derivate w.r.t. the parameters of the base kernel More... | |
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 \) More... | |
void | read (InArchive &ar) |
From ISerializable, reads a metric from an archive. More... | |
void | write (OutArchive &ar) const |
The kernel does not serialize anything. More... | |
Public Member Functions inherited from shark::AbstractKernelFunction< InputType > | |
AbstractKernelFunction () | |
const Features & | features () 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 |
Computes the squared distance in the kernel induced feature space. More... | |
Public Member Functions inherited from shark::AbstractMetric< InputType > | |
AbstractMetric () | |
virtual | ~AbstractMetric () |
virtual double | featureDistanceSqr (ConstInputReference x1, ConstInputReference x2) const=0 |
Computes the squared distance in the kernel induced feature space. More... | |
virtual RealMatrix | featureDistanceSqr (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2) const=0 |
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 () | |
Protected Attributes | |
AbstractKernelFunction< InputType > * | m_base |
kernel to scale More... | |
double | m_factor |
scaling factor More... | |
Protected Attributes inherited from shark::AbstractKernelFunction< InputType > | |
Features | m_features |
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 49 of file ScaledKernel.h.
typedef base_type::BatchInputType shark::ScaledKernel< InputType >::BatchInputType |
Definition at line 54 of file ScaledKernel.h.
typedef base_type::ConstBatchInputReference shark::ScaledKernel< InputType >::ConstBatchInputReference |
Definition at line 56 of file ScaledKernel.h.
typedef base_type::ConstInputReference shark::ScaledKernel< InputType >::ConstInputReference |
Definition at line 55 of file ScaledKernel.h.
|
inline |
Definition at line 58 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::factor(), shark::AbstractKernelFunction< InputType >::HAS_FIRST_INPUT_DERIVATIVE, shark::AbstractKernelFunction< InputType >::HAS_FIRST_PARAMETER_DERIVATIVE, shark::AbstractKernelFunction< InputTypeT >::hasFirstInputDerivative(), shark::AbstractKernelFunction< InputTypeT >::hasFirstParameterDerivative(), shark::ScaledKernel< InputType >::m_base, shark::AbstractKernelFunction< InputType >::m_features, RANGE_CHECK, and SHARK_ASSERT.
|
inline |
Definition at line 98 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_base.
Referenced by shark::NormalizeKernelUnitVariance< InputType >::train().
|
inlinevirtual |
creates the internal state of the kernel
Reimplemented from shark::AbstractKernelFunction< InputType >.
Definition at line 86 of file ScaledKernel.h.
References shark::AbstractKernelFunction< InputTypeT >::createState(), and shark::ScaledKernel< InputType >::m_base.
|
inlinevirtual |
Evaluates the kernel function.
Reimplemented from shark::AbstractKernelFunction< InputType >.
Definition at line 102 of file ScaledKernel.h.
References shark::AbstractKernelFunction< InputTypeT >::eval(), shark::ScaledKernel< InputType >::m_base, shark::ScaledKernel< InputType >::m_factor, and SIZE_CHECK.
Referenced by main().
|
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 107 of file ScaledKernel.h.
References shark::AbstractKernelFunction< InputTypeT >::eval(), shark::ScaledKernel< InputType >::m_base, and shark::ScaledKernel< InputType >::m_factor.
|
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]); The State object is filled in with data used in subsequent derivative computations.
Implements shark::AbstractKernelFunction< InputType >.
Definition at line 112 of file ScaledKernel.h.
References shark::AbstractKernelFunction< InputTypeT >::eval(), shark::ScaledKernel< InputType >::m_base, and shark::ScaledKernel< InputType >::m_factor.
|
inline |
Definition at line 90 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_factor.
Referenced by main(), and shark::ScaledKernel< InputType >::ScaledKernel().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 71 of file ScaledKernel.h.
|
inlinevirtual |
Return the number of parameters.
Reimplemented from shark::IParameterizable<>.
Definition at line 81 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_base, and shark::IParameterizable< VectorType >::numberOfParameters().
|
inlinevirtual |
Return the parameter vector.
Reimplemented from shark::IParameterizable<>.
Definition at line 74 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_base, and shark::IParameterizable< VectorType >::parameterVector().
|
inlinevirtual |
From ISerializable, reads a metric from an archive.
Reimplemented from shark::AbstractMetric< InputType >.
Definition at line 142 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_base, and shark::ScaledKernel< InputType >::m_factor.
|
inline |
Definition at line 93 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_factor, and RANGE_CHECK.
|
inlinevirtual |
Set the parameter vector.
Reimplemented from shark::IParameterizable<>.
Definition at line 77 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_base, and shark::IParameterizable< VectorType >::setParameterVector().
|
inlinevirtual |
calculates the weighted derivate w.r.t. argument \( x_1 \)
Reimplemented from shark::AbstractKernelFunction< InputType >.
Definition at line 129 of file ScaledKernel.h.
References shark::batchSize(), shark::ScaledKernel< InputType >::m_base, shark::ScaledKernel< InputType >::m_factor, SIZE_CHECK, and shark::AbstractKernelFunction< InputTypeT >::weightedInputDerivative().
|
inlinevirtual |
calculates the weighted derivate w.r.t. the parameters of the base kernel
Reimplemented from shark::AbstractKernelFunction< InputType >.
Definition at line 118 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_base, shark::ScaledKernel< InputType >::m_factor, and shark::AbstractKernelFunction< InputTypeT >::weightedParameterDerivative().
|
inlinevirtual |
The kernel does not serialize anything.
Reimplemented from shark::AbstractMetric< InputType >.
Definition at line 148 of file ScaledKernel.h.
References shark::ScaledKernel< InputType >::m_factor.
|
protected |
kernel to scale
Definition at line 155 of file ScaledKernel.h.
Referenced by shark::ScaledKernel< InputType >::base(), shark::ScaledKernel< InputType >::createState(), shark::ScaledKernel< InputType >::eval(), shark::ScaledKernel< InputType >::numberOfParameters(), shark::ScaledKernel< InputType >::parameterVector(), shark::ScaledKernel< InputType >::read(), shark::ScaledKernel< InputType >::ScaledKernel(), shark::ScaledKernel< InputType >::setParameterVector(), shark::ScaledKernel< InputType >::weightedInputDerivative(), and shark::ScaledKernel< InputType >::weightedParameterDerivative().
|
protected |
scaling factor
Definition at line 156 of file ScaledKernel.h.
Referenced by shark::ScaledKernel< InputType >::eval(), shark::ScaledKernel< InputType >::factor(), shark::ScaledKernel< InputType >::read(), shark::ScaledKernel< InputType >::setFactor(), shark::ScaledKernel< InputType >::weightedInputDerivative(), shark::ScaledKernel< InputType >::weightedParameterDerivative(), and shark::ScaledKernel< InputType >::write().