Weighted sum of kernel functions. More...
#include <shark/Models/Kernels/SubrangeKernel.h>
Public Member Functions | |
std::string | name () const |
From INameable: return the class name. | |
template<class Kernels , class Ranges > | |
SubrangeKernel (Kernels const &kernels, Ranges const &ranges) | |
Public Member Functions inherited from shark::WeightedSumKernel< InputType > | |
WeightedSumKernel (std::vector< AbstractKernelFunction< InputType > * > const &base) | |
std::string | name () const |
From INameable: return the class name. | |
bool | isAdaptive (std::size_t index) const |
Check whether m_base kernel index is adaptive. | |
void | setAdaptive (std::size_t index, bool b=true) |
Set adaptivity of m_base kernel index. | |
void | setAdaptiveAll (bool b=true) |
Set adaptivity of all m_base kernels. | |
double | weight (std::size_t index) |
Get the weight of a kernel. | |
void | setAdaptiveWeights (bool b) |
RealVector | parameterVector () const |
boost::shared_ptr< State > | createState () const |
creates the internal state of the kernel | |
void | setParameterVector (RealVector const &newParameters) |
std::size_t | numberOfParameters () const |
Return the number of parameters. | |
double | eval (ConstInputReference x1, ConstInputReference x2) const |
void | eval (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix &result) const |
void | eval (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix &result, State &state) 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 |
void | read (InArchive &ar) |
From ISerializable, reads a metric from an archive. | |
void | write (OutArchive &ar) const |
From ISerializable, writes a metric to an archive. | |
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 () | |
Additional Inherited Members | |
Public Types inherited from shark::WeightedSumKernel< InputType > | |
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< Feature > | Features |
This statement declares the member m_features. See Core/Flags.h for details. | |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
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 |
Protected Member Functions inherited from shark::WeightedSumKernel< InputType > | |
void | updateNumberOfParameters () |
template<class T > | |
void | weightedInputDerivativeImpl (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix const &coefficientsX2, State const &state, BatchInputType &gradient, typename boost::enable_if< boost::is_same< T, RealMatrix > >::type *dummy=0) const |
template<class T > | |
void | weightedInputDerivativeImpl (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix const &coefficientsX2, State const &state, BatchInputType &gradient, typename boost::disable_if< boost::is_same< T, RealMatrix > >::type *dummy=0) const |
Protected Attributes inherited from shark::WeightedSumKernel< InputType > | |
std::vector< tBase > | m_base |
collection of m_base kernels | |
double | m_weightsum |
sum of all weights | |
std::size_t | m_numParameters |
total number of parameters | |
bool | m_adaptWeights |
whether the weights should be adapted | |
Protected Attributes inherited from shark::AbstractKernelFunction< InputTypeT > | |
Features | m_features |
Weighted sum of kernel functions.
For a set of positive definite kernels \( k_1, \dots, k_n \) with positive coeffitients \( w_1, \dots, w_n \) the sum
\[ \tilde k(x_1, x_2) := \sum_{i=1}^{n} w_i \cdot k_i(x_1, x_2) \]
is again a positive definite kernel function. This still holds when the sub-kernels only operate of a subset of features, that is, when we have a direct sum kernel ( see e.g. the UCSC Technical Report UCSC-CRL-99-10: Convolution Kernels on Discrete Structures by David Haussler ).
This class is very similar to the WeightedSumKernel , except that it assumes it's inputs to be tuples of values \( x=(x_1,\dots, x_n) \) and we calculate the direct sum of kernels
\[ \tilde k(x, y) := \sum_{i=1}^{n} w_i \cdot k_i(x_i, y_i) \]
Internally, the weights are represented as \( w_i = \exp(\xi_i) \) to allow for unconstrained optimization.
The result of the kernel evaluation is devided by the sum of the kernel weights, so that in total, this amounts to fixing the sum of the weights to one.
Definition at line 190 of file SubrangeKernel.h.
|
inline |
Definition at line 203 of file SubrangeKernel.h.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 199 of file SubrangeKernel.h.