src.model.deeplearn.layer.light_kpconv_layer
Classes
|
- class src.model.deeplearn.layer.light_kpconv_layer.LightKPConvLayer(*args, **kwargs)
- Author:
Alberto M. Esmoris Pena
A light kernel point convolution layer redefines the typical
KPConvLayerto work with a single matrix of weights (instead of one per kernel point) and supporting an optional scale factor for each kernel point and input feature pair. The new tensor of weights is thus a matrix \(\pmb{W} \in \mathbb{R}^{D_{\mathrm{in}} \times D_{\mathrm{out}}}\). Also, all the scale factors can be represented as a matrix \(\pmb{A} \in \mathbb{R}^{m_q \times D_{\mathrm{in}}}\).See
KPConvLayer.- Variables:
A_trainable (bool) – Whether the scale factors are trainable (i.e., can be updated through backpropagation) or not.
built_A (bool) – Whether the matrix of scale factors \(\pmb{A} \in \mathbb{R}^{m_q \times D_{\mathrm{in}}}\) is built. Initially it is false, but it will be updated once the layer is built.
A_initializer – The initializer for the scale factors matrix.
A_regularizer – The regularizer for the scale factors matrix.
A_constraint – The constraint for the scale factors matrix.
- __init__(A_trainable=True, built_A=False, A_initializer='ones', A_regularizer=None, A_constraint=None, **kwargs)
See
KPConvLayerandKPConvLayer.__init__().
- build(dim_in)
Build the whole Light KPConv layer by calling the parent’s build method (see
KPConvLayer.build()) with the derivedLightKPConvLayer.build_W()logic and also build the \(\pmb{A} \in \mathbb{R}^{m_q \times D_{\mathrm{in}}}\) matrix.See
KPConvLayerandKPConvLayer.build()).
- compute_output_features(X, NX, NF)
Assist the
KPConvLayer.call()method by applying the point-wise convolutions with the single matrix of weights \(\pmb{W} \in \mathbb{R}^{D_{\mathrm{in}} \times D_{\mathrm{out}}}\) and the scale factors in \(\pmb{A} \in \mathbb{R}^{m_q \times D_{\mathrm{in}}}\).The new operation consists of redefining the kernel point convolution to work with the light kernel (where \(\mathcal{Q} = (\pmb{Q}, \pmb{W}))\) instead of \(\mathcal{Q} = (\pmb{Q}, \mathcal{W}))\)) such that:
\[\begin{split}\begin{aligned} \left(\pmb{P} * \mathcal{Q} \right) (\pmb{x}_{i*}) &=\; \sum_{\pmb{x}_{j*} \in \mathcal{N}_{\pmb{x}_{i*}}} \left[ \sum_{k=1}^{m_q}{ \max \; \left\{ 0,\, 1 - \dfrac{ \lVert{ \pmb{x}_{j*} - \pmb{x}_{i*} - \pmb{q}_{k*} }\rVert }{ \sigma } \right\} \biggl( \operatorname{diag}\left(\pmb{a}_{k*}\right) \pmb{W} \biggr)^{\intercal} } \right] \pmb{f}_{j*} \\ &=\; \sum_{\pmb{x}_{j*} \in \mathcal{N}_{\pmb{x}_{i*}}} \left(\operatorname{diag}\left[\sum_{k=1}^{m_q}{ \max \; \left\{ 0, 1 - \dfrac{ \lVert \pmb{x}_{j*} - \pmb{x}_{i*} - \pmb{q}_{k*} \rVert }{ \sigma } \right\} \pmb{a}_{k*} } \right] \pmb{W}\right)^{\intercal} \pmb{f}_{j*} \end{aligned}\end{split}\]See
KPConvLayer.compute_output_features()andKPConvLayer.call()for further details.
- build_W(Din)
Assist the
LightKPConvLayer.build()method in building the \(\mathcal{W} \in \mathbb{R}^{D_{\mathrm{in}} \times D_{\mathrm{out}}}\) tensor, i.e., the convolution weights.See
KPConvLayerandKPConvLayer.build().- Parameters:
Din (int) – The dimensionality of the input feature space \(D_{\mathrm{in}}\).
- 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, Wpast=None, Apast=None)
Export a set of files representing the state of the kernel for both the structure (Q) and the weights (W).
- Parameters:
dir_path (str) – The directory where the representation files will be exported.
out_prefix (str) – The output prefix to name the output files.
Wpast (
np.ndarrayortf.Tensoror None) – The weights of the kernel in the past.Apast (
np.ndarrayortf.Tensoror None) – The scale factors in the past.
- Returns:
Nothing at all, but the representation is exported as a set of files inside the given directory.