Gaussian radial basis function kernel. More...
#include <shark/Models/Kernels/GaussianRbfKernel.h>
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< State > | createState () 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 Features & | features () 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 |
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.
typedef base_type::BatchInputType shark::GaussianRbfKernel< InputType >::BatchInputType |
Definition at line 66 of file GaussianRbfKernel.h.
typedef base_type::ConstBatchInputReference shark::GaussianRbfKernel< InputType >::ConstBatchInputReference |
Definition at line 68 of file GaussianRbfKernel.h.
typedef base_type::ConstInputReference shark::GaussianRbfKernel< InputType >::ConstInputReference |
Definition at line 67 of file GaussianRbfKernel.h.
|
inline |
Definition at line 70 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::gamma(), shark::AbstractKernelFunction< InputType >::HAS_FIRST_INPUT_DERIVATIVE, shark::AbstractKernelFunction< InputType >::HAS_FIRST_PARAMETER_DERIVATIVE, shark::AbstractKernelFunction< InputType >::IS_NORMALIZED, shark::AbstractKernelFunction< InputTypeT >::m_features, shark::GaussianRbfKernel< InputType >::m_gamma, and shark::GaussianRbfKernel< InputType >::m_unconstrained.
|
inlinevirtual |
creates the internal state of the kernel
Reimplemented from shark::AbstractKernelFunction< InputTypeT >.
Definition at line 142 of file GaussianRbfKernel.h.
|
inline |
Definition at line 176 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma, and SIZE_CHECK.
|
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().
|
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.
|
inline |
Get the bandwidth parameter value.
Definition at line 108 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma.
Referenced by shark::GaussianRbfKernel< InputType >::GaussianRbfKernel(), main(), main(), and shark::GaussianRbfKernel< InputType >::setGamma().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 79 of file GaussianRbfKernel.h.
|
inlinevirtual |
Return the number of parameters.
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 103 of file GaussianRbfKernel.h.
|
inlinevirtual |
Return the parameter vector.
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 82 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma, and shark::GaussianRbfKernel< InputType >::m_unconstrained.
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractMetric< InputTypeT >.
Definition at line 130 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma, and shark::GaussianRbfKernel< InputType >::m_unconstrained.
|
inline |
Set the bandwidth parameter value.
shark::Exception | if gamma <= 0. |
Definition at line 119 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::gamma(), shark::GaussianRbfKernel< InputType >::m_gamma, and SHARK_RUNTIME_CHECK.
|
inlinevirtual |
Set the parameter vector.
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 92 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma, shark::GaussianRbfKernel< InputType >::m_unconstrained, and SHARK_RUNTIME_CHECK.
|
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().
|
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().
|
inline |
Definition at line 206 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma, SIZE_CHECK, and shark::State::toState().
|
inline |
Definition at line 182 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma, shark::GaussianRbfKernel< InputType >::m_unconstrained, SIZE_CHECK, and shark::State::toState().
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractMetric< InputTypeT >.
Definition at line 136 of file GaussianRbfKernel.h.
References shark::GaussianRbfKernel< InputType >::m_gamma, and shark::GaussianRbfKernel< InputType >::m_unconstrained.
|
protected |
kernel bandwidth parameter
Definition at line 275 of file GaussianRbfKernel.h.
Referenced by shark::GaussianRbfKernel< InputType >::eval(), shark::GaussianRbfKernel< InputType >::eval(), shark::GaussianRbfKernel< InputType >::eval(), shark::GaussianRbfKernel< InputType >::gamma(), shark::GaussianRbfKernel< InputType >::GaussianRbfKernel(), shark::GaussianRbfKernel< InputType >::parameterVector(), shark::GaussianRbfKernel< InputType >::read(), shark::GaussianRbfKernel< InputType >::setGamma(), shark::GaussianRbfKernel< InputType >::setParameterVector(), shark::GaussianRbfKernel< InputType >::setSigma(), shark::GaussianRbfKernel< InputType >::sigma(), shark::GaussianRbfKernel< InputType >::weightedInputDerivative(), shark::GaussianRbfKernel< InputType >::weightedParameterDerivative(), and shark::GaussianRbfKernel< InputType >::write().
|
protected |
use log storage
Definition at line 276 of file GaussianRbfKernel.h.
Referenced by shark::GaussianRbfKernel< InputType >::GaussianRbfKernel(), shark::GaussianRbfKernel< InputType >::parameterVector(), shark::GaussianRbfKernel< InputType >::read(), shark::GaussianRbfKernel< InputType >::setParameterVector(), shark::GaussianRbfKernel< InputType >::weightedParameterDerivative(), and shark::GaussianRbfKernel< InputType >::write().