|
|
lucid
0.0.1
Lifting-based Uncertain Control Invariant Dynamics
|
RKHS Gaussian kernel. More...
#include <GaussianKernel.h>
Public Member Functions | |
| GaussianKernel (Vector sigma_l, double sigma_f=1.0) | |
| Construct a new anisotropic GaussianKernel object with the given parameters. | |
| GaussianKernel (double sigma_l=1.0, double sigma_f=1.0) | |
| Construct a new isotropic GaussianKernel object with the given parameters. | |
| Scalar | sigma_f () const |
| Get read-only access to the \( \sigma_f \) value of the kernel. | |
| const Vector & | sigma_l () const |
| Get read-only access to the \( \sigma_l \) of the kernel. | |
| bool | is_stationary () const override |
| Check whether the kernel is is stationary. | |
| bool | is_isotropic () const |
| Check whether the kernel is isotropic. | |
| std::unique_ptr< Kernel > | clone () const override |
| Clone the kernel. | |
| void | set (Parameter parameter, double value) override |
Set the parameter to the indicated value. | |
| void | set (Parameter parameter, const Vector &value) override |
Set the parameter to the indicated value. | |
| std::string | to_string () const override |
| Get string representation of the kernel. | |
| template<class DerivedX, class DerivedY> | |
| Matrix | operator() (const MatrixBase< DerivedX > &x1, const MatrixBase< DerivedY > &x2) const |
| Compute the kernel function on \( x_1 \) and \( x_2 \), both being matrices of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
| template<class Derived> | |
| Matrix | operator() (const MatrixBase< Derived > &x) const |
| Compute the kernel function on \( \texttip{x}{Element of the vector space} \), which is a matrix of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
| template<class Derived> | |
| Matrix | operator() (const MatrixBase< Derived > &x, std::vector< Matrix > &gradient) const |
| Compute the kernel function on \( \texttip{x}{Element of the vector space} \), which is a matrix of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
| Matrix | operator() (ConstMatrixRef x1, ConstMatrixRef x2, std::vector< Matrix > *gradient) const |
| Compute the kernel function on \( x_1 \) and \( x_2 \), both being matrices of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
Public Member Functions inherited from lucid::Kernel | |
| template<class DerivedX, class DerivedY> | |
| Matrix | operator() (const MatrixBase< DerivedX > &x1, const MatrixBase< DerivedY > &x2) const |
| Compute the kernel function on \( x_1 \) and \( x_2 \), both being matrices of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
| template<class Derived> | |
| Matrix | operator() (const MatrixBase< Derived > &x) const |
| Compute the kernel function on \( \texttip{x}{Element of the vector space} \), which is a matrix of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
| template<class Derived> | |
| Matrix | operator() (const MatrixBase< Derived > &x, std::vector< Matrix > &gradient) const |
| Compute the kernel function on \( \texttip{x}{Element of the vector space} \), which is a matrix of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
Public Member Functions inherited from lucid::Parametrizable | |
| template<IsAnyOf< int, double, const Vector & > T> | |
| T | get (Parameter parameter) const |
Get the value of the specified parameter. | |
| template<Parameter P> | |
| internal::ParameterType< P >::ref_type | get () const |
Get the value of the specified parameter. | |
| std::variant< int, double, Vector > | get (Parameter parameter) const |
Get the value of the specified parameter. | |
| void | set (Parameter parameter, const std::variant< int, double, Vector > &value) |
Set the parameter to the indicated value. | |
| template<Parameter P> | |
| void | set (const std::variant< int, double, Vector > &value) |
Set the parameter to the indicated value. | |
| void | set (Parameter parameter, std::size_t idx, const std::variant< std::vector< int >, std::vector< double >, std::vector< Vector > > &values) |
Set the parameter to the index-th value among the indicated values. | |
| template<Parameter P> | |
| void | set (std::size_t idx, const std::variant< std::vector< int >, std::vector< double >, std::vector< Vector > > &values) |
Set the parameter to the index-th value among the indicated values. | |
| virtual void | set (Parameter parameter, int value) |
Set the parameter to the indicated value. | |
| template<Parameter P> | |
| void | set (typename internal::ParameterType< P >::ref_type value) |
Set the parameter to the indicated value. | |
| bool | has (const Parameter parameter) const |
Check whether the parameter is present in this object. | |
| Parameters | parameters () const |
| Get read-only access to the parameters of the parametrizable object. | |
| std::vector< Parameter > | parameters_list () const |
| Get read-only access to the list of parameters of the parametrizable object. | |
| Parametrizable & | load (const Parametrizable &o) |
Load parameters from another Parametrizable object. | |
Private Member Functions | |
| Matrix | apply_impl (ConstMatrixRef x1, ConstMatrixRef x2, std::vector< Matrix > *gradient) const override |
| Concrete implementation of operator()(). | |
| double | get_d (Parameter parameter) const override |
Get the value of the specified parameter. | |
| const Vector & | get_v (Parameter parameter) const override |
Get the value of the specified parameter. | |
Additional Inherited Members | |
Protected Member Functions inherited from lucid::Kernel | |
| Matrix | operator() (ConstMatrixRef x1, ConstMatrixRef x2, std::vector< Matrix > *gradient) const |
| Compute the kernel function on \( x_1 \) and \( x_2 \), both being matrices of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),. | |
Protected Member Functions inherited from lucid::Parametrizable | |
| virtual int | get_i (Parameter parameter) const |
Get the value of the specified parameter. | |
Protected Attributes inherited from lucid::Parametrizable | |
| Parameters | parameters_ |
| Parameters supported by this object. | |
RKHS Gaussian kernel.
Given a vector space \( \texttip{\mathcal{X}}{Polish sample vector space} \) and two vectors \( x_1, x_2 \in \mathcal{X} \), the Gaussian kernel is defined as
\[k(x_1, x_2) = \sigma_f^2 \exp\left(-\frac{1}{2} (x_1 - x_2)^T\Sigma(x_1 - x_2)\right) \]
where \( \Sigma = \text{diag}( \sigma _l )^{-2} \). The type of \( \sigma_l \) on kernel construction determines whether the kernel is isotropic or anisotropic. The kernel can be isotropic or anisotropic. In the anisotropic case, each dimension has its own length scale (i.e., \( \sigma_l \) value). In the isotropic case, the same length scale is used for all dimensions. If requested, the kernel can also compute the gradient of the kernel matrix with respect to \( \sigma_l \) and \( \sigma_f \).
|
explicit |
Construct a new anisotropic GaussianKernel object with the given parameters.
sigma_l are equal, the kernel will be anisotropic. This may play a role during hyperparameter optimization. sigma_l must contain at least one element all elements must be greater than 0 | sigma_l | \( \sigma_l \) value |
| sigma_f | \( \sigma_f \) value |
|
explicit |
Construct a new isotropic GaussianKernel object with the given parameters.
sigma_l must be greater than 0 | sigma_l | \( \sigma_l \) value. It is equal for all dimensions. |
| sigma_f | \( \sigma_f \) value |
|
overrideprivatevirtual |
Concrete implementation of operator()().
| x1 | \( \texttip{n_1}{Number of samples in the first matrix} \times \texttip{d}{Dimension of the vector space} \) first input matrix | |
| x2 | \( \texttip{n_2}{Number of samples in the second matrix} \times \texttip{d}{Dimension of the vector space} \) second input matrix | |
| [out] | gradient | pointer to store the gradient of the kernel function with respect to the kernel parameters |
Implements lucid::Kernel.
|
nodiscardoverridevirtual |
Clone the kernel.
Create a new instance of the kernel with the same parameters.
Implements lucid::Kernel.
|
nodiscardoverrideprivatevirtual |
Get the value of the specified parameter.
| parameter | parameter to retrieve |
parameter must be present and be associated with a value of type double. Reimplemented from lucid::Parametrizable.
|
nodiscardoverrideprivatevirtual |
Get the value of the specified parameter.
| parameter | parameter to retrieve |
parameter must be present and be associated with a value of type Vector. Reimplemented from lucid::Parametrizable.
|
inlinenodiscard |
Check whether the kernel is isotropic.
|
inlinenodiscardoverridevirtual |
Check whether the kernel is is stationary.
Implements lucid::Kernel.
|
inline |
Compute the kernel function on \( \texttip{x}{Element of the vector space} \), which is a matrix of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),.
\[k(x, x) . \]
| Derived | type of the input matrix |
| x | \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) input matrix |
|
inline |
Compute the kernel function on \( \texttip{x}{Element of the vector space} \), which is a matrix of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),.
\[k(x, x) . \]
Moreover, compute the gradient of the kernel function and store it in gradient.
| Derived | type of the input matrix |
| x | \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) input matrix | |
| [out] | gradient | gradient of the kernel function with respect to the parameters dimensions |
|
inline |
Compute the kernel function on \( x_1 \) and \( x_2 \), both being matrices of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),.
\[k(x_1, x_2) . \]
x1 and x2 must have the same number of columns. | DerivedX | type of the first input matrix |
| DerivedY | type of the second input matrix |
| x1 | \( \texttip{n_1}{Number of samples in the first matrix} \times \texttip{d}{Dimension of the vector space} \) first input row matrix |
| x2 | \( \texttip{n_2}{Number of samples in the second matrix} \times \texttip{d}{Dimension of the vector space} \) second input row matrix |
| Matrix lucid::Kernel::operator() | ( | ConstMatrixRef | x1, |
| ConstMatrixRef | x2, | ||
| std::vector< Matrix > * | gradient ) const |
Compute the kernel function on \( x_1 \) and \( x_2 \), both being matrices of row vectors in \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \),.
\[k(x_1, x_2) . \]
If gradient is not nullptr, the gradient of the kernel function with respect to the parameters is computed and stored in *gradient.
x1 and x2 must have the same number of columns. | x1 | \( \texttip{n_1}{Number of samples in the first matrix} \times \texttip{d}{Dimension of the vector space} \) first input matrix | |
| x2 | \( \texttip{n_2}{Number of samples in the second matrix} \times \texttip{d}{Dimension of the vector space} \) second input matrix | |
| [out] | gradient | pointer to store the gradient of the kernel function with respect to the kernel parameters |
|
overridevirtual |
Set the parameter to the indicated value.
| parameter | parameter to set |
| value | value to assign to the specified parameter |
parameter must be present and be associated with a value of type Vector. Reimplemented from lucid::Parametrizable.
|
overridevirtual |
Set the parameter to the indicated value.
| parameter | parameter to set |
| value | value to assign to the specified parameter |
parameter must be present and be associated with a value of type double. Reimplemented from lucid::Parametrizable.
|
inlinenodiscard |
Get read-only access to the \( \sigma_f \) value of the kernel.
|
inlinenodiscard |
Get read-only access to the \( \sigma_l \) of the kernel.
If the kernel is isotropic, the size of the vector will be 1, regardless of the input dimension.
|
nodiscardoverridevirtual |
Get string representation of the kernel.
Reimplemented from lucid::Kernel.