src.model.deeplearn.layer.rbf_feat_extract_layer
Classes
|
- class src.model.deeplearn.layer.rbf_feat_extract_layer.RBFFeatExtractLayer(*args, **kwargs)
- Author:
Alberto M. Esmoris Pena
A RBF feature extraction layer is governed by a matrix \(\pmb{Q}\) representing the kernel’s structure space in a \(n_x\)-dimensional Euclidean space such that:
\[\pmb{Q} \in \mathbb{R}^{K \times n_x}\]For 3D point clouds, \(n_x=3\) and the matrix \(\pmb{Q}\) represents the coordinates of the kernel points in a 3D space centered at zero.
On top of that, a RBF feature extraction layer is also governed by a \(\pmb{\omega} \in \mathbb{R}^K\) vector that parametrizes the curvature of each radial basis function.
The output of a RBF feature extraction layer when considering a Gaussian kernel is given by the expression below:
\[\pmb{Y} \in \mathbb{R}^{m \times K} \;\text{s.t.}\; y_{ij} = \exp\biggl({ - \dfrac{ \lVert{\pmb{x_{i*}}-\pmb{q_{j*}}}\rVert^2 }{ \omega_{j}^2 }}\biggr)\]The \(\pmb{Y}\) matrix can be understood as a feature matrix extracted from the \(m\) input points through its interaction with the kernel.
- Variables:
structure_initialization_type (str) – The type of initialization strategy for the kernel’s structure space.
max_radii (
np.ndarrayof float) – The radius of the last ellipsoid along each axis \(\pmb{r}^* \in \mathbb{R}^{n_x}\).radii_resolution (int) – How many concentric ellipsoids must be considered \(n \in \mathbb{Z}_{>0}\) (the first one is the center point, the last one is the biggest outer ellipsoid).
angular_resolutions (
np.ndarrayof int) – How many angles consider for each ellipsoid \((m_1, \ldots, m_n)\).kernel_function_type (str) – The type of kernel function to be used (e.g., “Gaussian” or “Markov”).
kernel_function (function) – The kernel function to be used.
num_kernel_points (int) – The number of points representing the kernel \(K \in \mathbb{Z}_{>0}\).
Q (
tf.Tensor) – The kernel’s structure space matrixtrainable_Q (bool) – Flag to control whether Q is trainable or not.
built_Q (bool) – Flag to control whether Q has been built or not.
omega (
tf.Tensor) – The vector of kernel’s sizes (can be thought as a curvature).trainable_omega (bool) – Flag to control whether omega is trainable or not.
built_omega (bool) – Flag to control whether omega has been built or not.
- __init__(max_radii, radii_resolution=4, angular_resolutions=(1, 2, 4, 8), kernel_function_type='Gaussian', structure_initialization_type='concentric_ellipsoids', structure_dimensionality=3, trainable_Q=True, trainable_omega=True, built_Q=False, built_omega=False, **kwargs)
See
Layerandlayer.Layer.__init__().
- build(dim_in)
Build the \(\pmb{Q} \in \mathbb{K \times n_x}\) matrix representing the kernel’s structure, and the \(\pmb{\omega}\) vector representing the kernel’s sizes (think about curvature).
The \(\pmb{Q}\) matrix represents the disposition of the kernel’s points while the \(\pmb{\omega}\) vector represents the size of each radial basis function. The size of a radial basis function for typical Gaussian kernels can be seen as the parameter governing the curvature of the exponential.
See
Layerandlayer.Layer.build().
- call(inputs, training=False, mask=False)
The computation of the \(\pmb{Y} \in \mathbb{R}^{m \times K}\) matrix of output features. For example, for a Gaussian kernel this matrix would be:
\[y_{ij} = \exp\left(-\dfrac{ \lVert{\pmb{x_{i*}} - \pmb{q_{j*}}}\rVert^2 }{ \omega_j^2 }\right)\]Where \(\pmb{x_{i*}}\) is the i-th input point and \(\pmb{q_{j*}}\) is the j-th kernel point.
- Returns:
The extracted output features.
- Return type:
tf.Tensor
- compute_gaussian_kernel(D_squared)
Compute a Gaussian kernel function.
\[y_{ij} = \exp\left( - \dfrac{ \lVert{\pmb{x_{i*}}} - \pmb{q_{j*}}\rVert^2 }{ \omega_{j}^2 } \right)\]- Returns:
The computed Gaussian kernel function.
- Return type:
tf.Tensor
- compute_markov_kernel(D_squared)
Compute a Markov kernel function.
\[y_{ij} = \exp\left( - \dfrac{ \lVert{\pmb{x_{i*}}} - \pmb{q_{j*}}\rVert }{ \omega_{j}^2 } \right)\]- Returns:
The computed Markov kernel function.
- Return type:
tf.Tensor
- get_config()
Return necessary data to serialize the layer
- classmethod from_config(config)
Use given config data to deserialize the layer
- export_representation(dir_path, out_prefix=None, Qpast=None)
Export a set of files representing the state of the kernel’s structure.
- Parameters:
dir_path (str) – The directory where the representation files will be exported.
out_prefix (str) – The output prefix to name the output files.
Qpast (
np.ndarrayortf.Tensoror None) – The structure matrix of the layer in the past.
- Returns:
Nothing at all, but the representation is exported as a set of files inside the given directory.