|
|
lucid
0.0.1
Lifting-based Uncertain Control Invariant Dynamics
|
Truncated Fourier feature map. More...
#include <TruncatedFourierFeatureMap.h>
Public Member Functions | |
| TruncatedFourierFeatureMap (int num_frequencies, const Matrix &prob_per_dim, const Matrix &omega_per_dim, ConstVectorRef sigma_l, Scalar sigma_f, const RectSet &X_bounds) | |
| Construct a truncated Fourier feature map. | |
| TruncatedFourierFeatureMap (int num_frequencies, const Matrix &prob_per_dim, const Matrix &omega_per_dim, double sigma_l, Scalar sigma_f, const RectSet &X_bounds) | |
| Construct a truncated Fourier feature map. | |
| Vector | map_vector (ConstVectorRef x) const |
| Given a \( \texttip{d}{Dimension of the vector space} \) dimensional vector \( \texttip{x}{Element of the vector space} \), project it to the unit hypercube \( [0, 1]^d \), then compute the feature map. | |
| Vector | invert_vector (ConstVectorRef y) const |
| Given a @2M+1 dimensional vector \( \texttip{y}{Element of the vector space} \), invert the feature map to obtain the original input vector. | |
| Matrix | map_matrix (ConstMatrixRef x) const |
| Given an \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) dimensional matrix \( \texttip{x}{Element of the vector space} \), project each row vector to the unit hypercube \( [0, 1]^d \), then compute the feature map. | |
| Dimension | dimension () const |
| Get read-only access to the dimension of the the feature map space. | |
| const Matrix & | omega () const |
| Get read-only access to the frequency matrix of the truncated Fourier feature map. | |
| const Vector & | weights () const |
| Get read-only access to the weights matrix of the truncated Fourier feature map. | |
| int | num_frequencies () const |
| Get read-only access to the number of frequencies per dimension of the truncated Fourier feature map. | |
| Scalar | captured_probability () const |
| Get read-only access to the probability captured by the Fourier expansion of the truncated Fourier feature map. | |
| const RectSet & | X_bounds () const |
| Get read-only access to the limits of the original input space. | |
| double | sigma_f () const |
| Get read-only access to the sigma_f value of the truncated Fourier feature map. | |
| const Vector & | sigma_l () const |
| Get read-only access to the sigma_l value of the truncated Fourier feature map. | |
| virtual RectSet | get_periodic_set () const |
| Return the periodic input domain for this linear truncated Fourier map. | |
| std::unique_ptr< FeatureMap > | clone () const override |
| Clone the feature map. | |
Public Member Functions inherited from lucid::FeatureMap | |
| Matrix | operator() (ConstMatrixRef x) const |
| Apply the feature map to a vector. | |
| Matrix | invert (ConstMatrixRef y) const |
| Apply the inverse feature map to a vector. | |
| virtual std::string | to_string () const |
| Obtain the string representation of this object. | |
Protected Member Functions | |
| Matrix | apply_impl (ConstMatrixRef x) const override |
| Given an \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) dimensional matrix \( \texttip{x}{Element of the vector space} \), project each row vector to the unit hypercube \( [0, 1]^d \), then compute the feature map. | |
| Matrix | invert_impl (ConstMatrixRef y) const override |
| Concrete implementation of invert(). | |
Protected Attributes | |
| int | num_frequencies_ |
| Number of frequencies per dimension. | |
| Matrix | omega_ |
| Frequencies matrix. | |
| Vector | weights_ |
| Weights matrix. | |
| Scalar | sigma_f_ |
| \( \sigma_f \) value | |
| Vector | sigma_l_ |
| \( \sigma_l \) vector | |
| RectSet | X_bounds_ |
| Limits of the input space expressed as a matrix. The set is a rectangle. | |
| Scalar | captured_probability_ |
| Probability captured by the Fourier expansion. NaN if not computed. | |
Truncated Fourier feature map.
It maps vectors from \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \) to a higher-dimensional space using the truncated Fourier series. The number of frequencies, \( M > 0 \), determines the dimension of the output space. All possible combinations of frequencies are computed for each input dimension. Therefore, the output vector has a dimension of \( 2^d M + 1 \). The feature map is computed as
\[\phi_{M}(x) = \sigma_{f}\begin{bmatrix} w_{0}\\ \sqrt{2}w_{1}\cos(\omega_{1}^{\top}P(x))\\ \sqrt{2}w_{1}\sin(\omega_{1}^{\top}P(x))\\ \vdots\\ \sqrt{2}w_{M}\cos(\omega_{M}^{\top}P(x))\\ \sqrt{2}w_{M}\sin(\omega_{M}^{\top}P(x)) \end{bmatrix}, \]
The way the weights and omegas are computed depends on the subclass.
| lucid::TruncatedFourierFeatureMap::TruncatedFourierFeatureMap | ( | int | num_frequencies, |
| const Matrix & | prob_per_dim, | ||
| const Matrix & | omega_per_dim, | ||
| ConstVectorRef | sigma_l, | ||
| Scalar | sigma_f, | ||
| const RectSet & | X_bounds ) |
Construct a truncated Fourier feature map.
num_frequencies must be greater than 0. sigma_f must be greater than 0. | num_frequencies | number of frequencies per dimension. Includes the zero frequency |
| prob_per_dim | probability distribution of frequencies per dimension, \( \mathbb{P}(\zeta_j) \) |
| omega_per_dim | matrix omega where each row is a dimension and each column is a frequency coefficient |
| sigma_l | length scales per dimension |
| sigma_f | scaling factor |
| X_bounds | domain of the input space, \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \) |
| lucid::TruncatedFourierFeatureMap::TruncatedFourierFeatureMap | ( | int | num_frequencies, |
| const Matrix & | prob_per_dim, | ||
| const Matrix & | omega_per_dim, | ||
| double | sigma_l, | ||
| Scalar | sigma_f, | ||
| const RectSet & | X_bounds ) |
Construct a truncated Fourier feature map.
num_frequencies must be greater than 0. sigma_f must be greater than 0. | num_frequencies | number of frequencies per dimension. Includes the zero frequency |
| prob_per_dim | probability distribution of frequencies per dimension, \( \mathbb{P}(\zeta_j) \) |
| omega_per_dim | matrix omega where each row is a dimension and each column is a frequency coefficient |
| sigma_l | length scales per dimension |
| sigma_f | scaling factor |
| X_bounds | domain of the input space, \( \texttip{\mathcal{X}}{Polish sample vector space} \subseteq \mathbb{R}^d \) |
|
nodiscardoverrideprotectedvirtual |
Given an \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) dimensional matrix \( \texttip{x}{Element of the vector space} \), project each row vector to the unit hypercube \( [0, 1]^d \), then compute the feature map.
| x | input vector |
Implements lucid::FeatureMap.
|
inlinenodiscard |
Get read-only access to the probability captured by the Fourier expansion of the truncated Fourier feature map.
NaN if not computed
|
nodiscardoverridevirtual |
Clone the feature map.
Create a new instance of the feature map with the same parameters.
Implements lucid::FeatureMap.
|
inlinenodiscard |
Get read-only access to the dimension of the the feature map space.
|
nodiscardvirtual |
Return the periodic input domain for this linear truncated Fourier map.
We want to find a space such that the smallest frequency is able to complete a full period. Given that frequencies are defined as \( \omega P(x) \), where \( P(x) \) is the projection to the unit hypercube of the original domain, we want to find the upper bound of the periodic domain \( \bar{x} \) such that
\[\omega P(\bar{x}) = 2\pi \]
for the smallest \( \omega \). Graphically,
Notice how the lower bound remains fixed, while the upper bound is shifted to create the periodic domain.
Reimplemented in lucid::ConstantTruncatedFourierFeatureMap, and lucid::LinearTruncatedFourierFeatureMap.
|
nodiscardoverrideprotectedvirtual |
Concrete implementation of invert().
| y | \( n \times M \) input vector in the feature space |
Implements lucid::FeatureMap.
|
nodiscard |
Given a @2M+1 dimensional vector \( \texttip{y}{Element of the vector space} \), invert the feature map to obtain the original input vector.
| y | input vector in the feature space |
|
nodiscard |
Given an \( \texttip{n}{Number of samples} \times \texttip{d}{Dimension of the vector space} \) dimensional matrix \( \texttip{x}{Element of the vector space} \), project each row vector to the unit hypercube \( [0, 1]^d \), then compute the feature map.
| x | input vector |
|
nodiscard |
Given a \( \texttip{d}{Dimension of the vector space} \) dimensional vector \( \texttip{x}{Element of the vector space} \), project it to the unit hypercube \( [0, 1]^d \), then compute the feature map.
| x | input vector |
|
inlinenodiscard |
Get read-only access to the number of frequencies per dimension of the truncated Fourier feature map.
|
inlinenodiscard |
Get read-only access to the frequency matrix of the truncated Fourier feature map.
|
inlinenodiscard |
Get read-only access to the sigma_f value of the truncated Fourier feature map.
|
inlinenodiscard |
Get read-only access to the sigma_l value of the truncated Fourier feature map.
|
inlinenodiscard |
Get read-only access to the weights matrix of the truncated Fourier feature map.
|
inlinenodiscard |
Get read-only access to the limits of the original input space.