src.model.deeplearn.layer.geometric_affine_layer
Classes
|
- class src.model.deeplearn.layer.geometric_affine_layer.GeometricAffineLayer(*args, **kwargs)
- Author:
Alberto M. Esmoris Pena
A geometric affine layer receives batches of \(R\) points with \(n_f\) input features each, and \(\kappa\) known neighbors in the same space. These inputs are used to compute an output feature space of \(R\) points with \(n_f\) features each. In doing so, the indexing tensor \(\mathcal{N} \in \mathbb{Z}^{B \times R \times \kappa}\) is used to link \(\kappa\) neighbors for each of the \(R\) input points in each of the \(B\) input batches.
The layer applies the following geometric affine transformation:
\[\pmb{\hat{f}_{ik*}} = \pmb{\alpha} \odot \dfrac{ \pmb{f}_{k_i*} - \pmb{f}_{i*} }{ \sigma + \epsilon } + \pmb{\beta}\]where \(k_i\) refers to the \(k\)-th neighbor of the \(i\)-th point and
\[\sigma = \sqrt{ \left( R \kappa n_f \right)^{-1} \sum_{i=1}^{R}{\sum_{\pmb{x}_{k*} \in \mathcal{N}(\pmb{x}_{i*})}{ \sum_{j=1}^{n_f}{\bigl( f_{kj} - f_{ij} \bigr)^2} }} } .\]Note that in this model the vectors of weights (i.e., trainable parameters) are \(\pmb{\alpha}, \pmb{\beta} \in \mathbb{R}^{n_f}\). Besides, the \(\epsilon\) value use for numerical stability is often set to \(\epsilon = 10^{-5}\).
The output is a tensor \(\mathcal{\widehat{F}} \in \mathbb{R}^{B \times R \times \kappa \times n_f}\) that contains the batch-wise transformed features for all the points in each local neighborhood.
This layer is inspired in the PointMLP paper (https://doi.org/10.48550/arXiv.2202.07123).
- Variables:
eps (float) – The numerical stability constant \(\epsilon\) that will be added to \(\sigma\) in the denominator. By default it is \(10^{-5}\).
built_alpha (bool) – Whether the weights vector \(\pmb{\alpha}\) is built. Initially it is false, but it will be updated once the layer is built.
built_beta (bool) – Whether the weights vector \(\pmb{\beta}\) is built. Initially it is false, but it will be updated once the layer is built.
alpha_initializer – The initializer for the vector of weights \(\pmb{\alpha}\).
alpha_regularizer – The regularizer for the vector of weights \(\pmb{\alpha}\).
alpha_constraint – The constraint for the vector of weights \(\pmb{\alpha}\).
beta_initializer – The initializer for the vector of weights \(\pmb{\beta}\).
beta_regularizer – The regularizer for the vector of weights \(\pmb{\beta}\).
beta_constraint – The constraint for the vector of weights \(\pmb{\beta}\).
- __init__(eps=1e-05, built_alpha=False, built_beta=False, alpha_initializer=None, alpha_regularizer=None, alpha_constraint=None, beta_initializer=None, beta_regularizer=None, beta_constraint=None, **kwargs)
See
LayerandLayer.__init__().
- build(dim_in)
Build the weight vectors.
See
Layerandlayer.Layer.build().
- call(inputs, training=False, mask=False)
Compute the GeometricAffineLayer on an input batch.
- Parameters:
inputs –
The input such that:
- – inputs[0]
is the structure space tensor representing the geometry of the many receptive fields in the batch.
\[\mathcal{X} \in \mathbb{R}^{K \times R \times n_x}\]- – inputs[1]
is the feature space tensor representing the features of the many receptive fields in the batch.
\[\mathcal{F} \in \mathbb{R}^{K \times R \times n_f}\]- – inputs[2]
is the indexing tensor representing the neighborhoods of \(\kappa\) neighbors for each input point, in the same space.
\[\mathcal{N} \in \mathbb{Z}^{K \times R \times \kappa}\]
- Returns:
The output feature space \(\mathcal{\widehat{F}} \in \mathbb{R}^{B \times R \times \kappa \times n_f}\).
- compute_sigma(F, N)
Assist the
GeometricAffineLayer.call()method by computing \(\sigma\).
- compute_output_features(diffs, sigma)
Assist the
GeometricAffineLayer.call()method by computing the geometric affine transformation of the neighborhood-wise features.
- get_config()
Return necessary data to serialize the layer.
- classmethod from_config(config)
Use given config data to deserialize the layer.