|
|
lucid
0.0.1
Lifting-based Uncertain Control Invariant Dynamics
|
Truncated Fourier feature map using same-sized intervals between each interval of the normal distribution, from the origin to 3 standard deviations on each side. More...
#include <LinearTruncatedFourierFeatureMap.h>
Public Member Functions | |
| std::unique_ptr< FeatureMap > | clone () const override |
| Clone the feature map. | |
| RectSet | get_periodic_set () const override |
| Return the periodic input domain for this linear truncated Fourier map. | |
| std::string | to_string () const override |
| Obtain the string representation of this object. | |
Public Member Functions inherited from 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. | |
| 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. | |
| 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. | |
Additional Inherited Members | |
Protected Member Functions inherited from lucid::TruncatedFourierFeatureMap | |
| 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 inherited from lucid::TruncatedFourierFeatureMap | |
| 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 using same-sized intervals between each interval of the normal distribution, from the origin to 3 standard deviations on each side.
Recall the structure of the feature map
\[ \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} \]
After defining the quantity \( \vartheta = 6 \sigma_l^{-1} / (2M-1) \), we compute the the \( \omega_j \) as
\[\omega_j = \text{diag}(\zeta_j) \cdot \vartheta, \quad 1 \le j \le M , \]
and the weights from the n-dimensional cumulative distribution function of the normal distribution with standard deviation \( \sigma_l^{-1} \), i.e.
\[ w_j^2 = \int_{\omega_j - \vartheta/2}^{\omega_j + \vartheta/2}\mathcal{N}(d\xi|0,\Sigma^{-1}), \quad 0 \le j \le M . \]
where \( \zeta_j \in \mathbb{N}^n_{\ge 0}\) is a multi-index vector and \( \Sigma = \text{diag}(\sigma_l)^2 \). For example, let \( \sigma_l^{-1} = 3 \) and \( M = 4 \) frequencies. We split the normal distribution into 4 intervals on each side of the origin, as shown in the plot below. We only highlight the positive side, as the negative side is symmetric. Then, we sum each interval with its symmetric counterpart to get the weights.
|
nodiscardoverridevirtual |
Clone the feature map.
Create a new instance of the feature map with the same parameters.
Implements lucid::FeatureMap.
|
nodiscardoverridevirtual |
Return the periodic input domain for this linear truncated Fourier map.
Given a linear truncated feature map \( \texttip{\phi_M(x)}{Feature map considering M frequencies, including the 0th frequency} \), its smallest frequency is
\[\frac{6\sigma_l^{-1}}{2M-1} P(x) , \]
where \( P(x) \) is the projection to the unit hypercube of the original domain and \( M \) is the number of frequencies per dimension (including the zero frequency). We want to find the upper bound of the periodic domain \( \bar{x} \) such that
\[\frac{6\sigma_l^{-1}}{2M-1} P(\bar{x}) = 2\pi . \]
Since \( P(x) = \frac{x - x_{min}}{x_{max} - x_{min}} \), we have that
\[\bar{x} = x_{min} + 2\pi \frac{2M-1}{6\sigma_l^{-1}} (x_{max} - x_{min}) . \]
Graphically,
Notice how the lower bound remains fixed, while the upper bound is shifted to create the periodic domain.
Reimplemented from lucid::TruncatedFourierFeatureMap.
|
nodiscardoverridevirtual |
Obtain the string representation of this object.
Reimplemented from lucid::FeatureMap.