Product of kernel functions. More...
#include <shark/Models/Kernels/ProductKernel.h>
Inheritance diagram for shark::ProductKernel< InputType >:Public Types | |
| typedef AbstractKernelFunction< InputType > | SubKernel |
| 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. | |
| 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 |
Public Member Functions | |
| ProductKernel () | |
| Default constructor. | |
| ProductKernel (SubKernel *k1, SubKernel *k2) | |
| Constructor for a product of two kernels. | |
| ProductKernel (std::vector< SubKernel * > kernels) | |
| std::string | name () const |
| From INameable: return the class name. | |
| void | addKernel (SubKernel *k) |
| Add one more kernel to the expansion. | |
| 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. | |
| double | eval (ConstInputReference x1, ConstInputReference x2) const |
| evaluates the kernel function | |
| 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). | |
| void | eval (ConstBatchInputReference batchX1, ConstBatchInputReference batchX2, RealMatrix &result, State &state) const |
| Evaluates the subset of the KernelGram matrix which is defined by X1(rows) and X2 (columns). | |
| void | read (InArchive &ar) |
| From ISerializable. | |
| void | write (OutArchive &ar) const |
| From ISerializable. | |
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 |
| virtual boost::shared_ptr< State > | createState () const |
| Creates an internal state of the kernel. | |
| double | operator() (ConstInputReference x1, ConstInputReference x2) const |
| Convenience operator which evaluates the kernel function. | |
| 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 () |
| virtual double | featureDistanceSqr (ConstInputReference x1, ConstInputReference x2) const =0 |
| Computes the squared distance in the kernel induced feature space. | |
| 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. | |
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 | |
| std::vector< SubKernel * > | m_kernels |
| vector of sub-kernels | |
| std::size_t | m_numberOfParameters |
| total number of parameters in the product (this is redundant information) | |
Protected Attributes inherited from shark::AbstractKernelFunction< InputType > | |
| Features | m_features |
Product of kernel functions.
Definition at line 61 of file ProductKernel.h.
| typedef base_type::BatchInputType shark::ProductKernel< InputType >::BatchInputType |
Definition at line 67 of file ProductKernel.h.
| typedef base_type::ConstBatchInputReference shark::ProductKernel< InputType >::ConstBatchInputReference |
Definition at line 69 of file ProductKernel.h.
| typedef base_type::ConstInputReference shark::ProductKernel< InputType >::ConstInputReference |
Definition at line 68 of file ProductKernel.h.
| typedef AbstractKernelFunction<InputType> shark::ProductKernel< InputType >::SubKernel |
Definition at line 66 of file ProductKernel.h.
|
inline |
Default constructor.
Definition at line 71 of file ProductKernel.h.
References shark::AbstractKernelFunction< InputType >::IS_NORMALIZED, and shark::AbstractKernelFunction< InputType >::m_features.
|
inline |
Constructor for a product of two kernels.
Definition at line 80 of file ProductKernel.h.
References shark::ProductKernel< InputType >::addKernel(), shark::AbstractKernelFunction< InputType >::IS_NORMALIZED, and shark::AbstractKernelFunction< InputType >::m_features.
|
inline |
Definition at line 89 of file ProductKernel.h.
References shark::ProductKernel< InputType >::addKernel(), shark::AbstractKernelFunction< InputType >::IS_NORMALIZED, and shark::AbstractKernelFunction< InputType >::m_features.
|
inline |
Add one more kernel to the expansion.
| k | The pointer is expected to remain valid during the lifetime of the ProductKernel object. |
Definition at line 107 of file ProductKernel.h.
References shark::AbstractKernelFunction< InputType >::IS_NORMALIZED, shark::AbstractKernelFunction< InputTypeT >::isNormalized(), shark::AbstractKernelFunction< InputType >::m_features, shark::ProductKernel< InputType >::m_kernels, shark::ProductKernel< InputType >::m_numberOfParameters, shark::IParameterizable< VectorType >::numberOfParameters(), shark::TypedFlags< Flag >::reset(), and SHARK_ASSERT.
Referenced by shark::ProductKernel< InputType >::ProductKernel(), and shark::ProductKernel< InputType >::ProductKernel().
|
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 151 of file ProductKernel.h.
References shark::batchSize(), and shark::ProductKernel< InputType >::m_kernels.
|
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 165 of file ProductKernel.h.
References shark::ProductKernel< InputType >::eval().
|
inlinevirtual |
evaluates the kernel function
This function returns the product of all sub-kernels.
Reimplemented from shark::AbstractKernelFunction< InputType >.
Definition at line 144 of file ProductKernel.h.
References shark::ProductKernel< InputType >::eval(), and shark::ProductKernel< InputType >::m_kernels.
Referenced by shark::ProductKernel< InputType >::eval(), and shark::ProductKernel< InputType >::eval().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 100 of file ProductKernel.h.
|
inlinevirtual |
Return the number of parameters.
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 137 of file ProductKernel.h.
References shark::ProductKernel< InputType >::m_numberOfParameters.
|
inlinevirtual |
Return the parameter vector.
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 115 of file ProductKernel.h.
References shark::ProductKernel< InputType >::m_kernels, and shark::ProductKernel< InputType >::m_numberOfParameters.
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractMetric< InputTypeT >.
Definition at line 170 of file ProductKernel.h.
References shark::ProductKernel< InputType >::m_kernels, and shark::ProductKernel< InputType >::m_numberOfParameters.
|
inlinevirtual |
Set the parameter vector.
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 126 of file ProductKernel.h.
References shark::ProductKernel< InputType >::m_kernels, shark::ProductKernel< InputType >::m_numberOfParameters, and SIZE_CHECK.
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractMetric< InputTypeT >.
Definition at line 178 of file ProductKernel.h.
References shark::ProductKernel< InputType >::m_kernels, and shark::ProductKernel< InputType >::m_numberOfParameters.
|
protected |
vector of sub-kernels
Definition at line 186 of file ProductKernel.h.
Referenced by shark::ProductKernel< InputType >::addKernel(), shark::ProductKernel< InputType >::eval(), shark::ProductKernel< InputType >::eval(), shark::ProductKernel< InputType >::parameterVector(), shark::ProductKernel< InputType >::read(), shark::ProductKernel< InputType >::setParameterVector(), and shark::ProductKernel< InputType >::write().
|
protected |
total number of parameters in the product (this is redundant information)
Definition at line 187 of file ProductKernel.h.
Referenced by shark::ProductKernel< InputType >::addKernel(), shark::ProductKernel< InputType >::numberOfParameters(), shark::ProductKernel< InputType >::parameterVector(), shark::ProductKernel< InputType >::read(), shark::ProductKernel< InputType >::setParameterVector(), and shark::ProductKernel< InputType >::write().