src.model.deeplearn.layer.features_upsampling_layer

Classes

FeaturesUpsamplingLayer(*args, **kwargs)

class src.model.deeplearn.layer.features_upsampling_layer.FeaturesUpsamplingLayer(*args, **kwargs)
Author:

Alberto M. Esmoris Pena

A features upsampling layer receives batches of \(R\) points with \(n_f\) features each and upsamples them to \(m\) points with \(n_f\) features each.

It can use a mean-based filter to propagate the features (see FeaturesUpsamplingLayer.mean_filter()), a max-based filter (see FeaturesUpsamplingLayer.max_filter()) a Gaussian-like filter to propagate the features considering the distances between the points (see FeaturesUpsamplingLayer.gaussian_filter()), or an exponential-like filter to propagate the features considering the distances to the contrary as the Gaussian-like filter, i.e., assigning greater weights to points fruther from the center (see FeaturesUpsamplingLayer.exponential_filter()). Alternatively, a simpler nearest-neighbor filter can be used too (see FeaturesUpsamplingLayer.nearest_filter()).

The input feature space is a tensor \(\mathcal{F} \in \mathbb{R}^{K \times R \times n_f}\) whose slices represent independent receptive fields. The output feature space is an upsampled version of the input one \(\mathcal{Y} \in \mathbb{R}^{K \times m \times n_f}\). Where \(K\) is the batch size.

Variables:
  • filter (str) – The name of the filter to be used. Either "mean", "gaussian", "exponential", or "nearest".

  • filter_f (Callable) – The method to be used for filtering, derived from the filter attribute.

__init__(filter='mean', **kwargs)

See Layer and layer.Layer.__init__().

build(dim_in)

See Layer and layer.Layer.build().

call(inputs, training=False, mask=False)

Upsample the features from \(R\) input points to \(m\) output points, where \(m \geq R\).

Parameters:

inputs

The inputs such that:

– inputs[0]

is the structure space tensor before the upsampling.

\[\mathcal{X}_a \in \mathbb{R}^{K \times R \times n_x}\]
– inputs[1]

is the structure space tensor after the upsampling.

\[\mathcal{X}_b \in \mathbb{R}^{K \times m \times n_x}\]
– inputs[2]

is the feature space tensor before the upsampling.

\[\mathcal{F} \in \mathbb{R}^{K \times R \times n_f}\]
– inputs[3]

is the indexing tensor representing the upsampling topology \(\mathcal{N}^U \in \mathbb{Z}^{K \times m \times n_n}\), i.e., for each point in the upsampled space to what points it is connected in the non-upsampled space.

Returns:

The upsampled features \(\mathcal{Y} \in \mathbb{R}^{K \times m \times n_f}\)

static mean_filter(Xa, Xb, Fin, NU)
\[y_{kij} = \dfrac{1}{n_n} \sum_{p=1}^{n_n}{ f_{kn_{kip}^Uj} }\]
Returns:

\(\mathcal{Y} \in \mathbb{R}^{K \times m \times n_f}\)

static max_filter(Xa, Xb, Fin, NU)
\[y_{kij} = \max_{1 \leq p \leq n_n} \quad \left\{ f_{kn_{kip}^Uj} \right\}\]
Returns:

\(\mathcal{Y} \in \mathbb{R}^{K \times m \times n_f}\)

static gaussian_filter(Xa, Xb, Fin, NU)
\[y_{kij} = \left(\sum_{p=1}^{n_n}{g_{kip}}\right)^{-1} \sum_{p=1}^{n_n}{ g_{kip} f_{kn_{kip}^Uj} }\]

Where:

\[g_{kip} = \exp\left(- \dfrac{ \lVert (\mathcal{X}_a)_{kn_{kip}^U*} - (\mathcal{X}_b)_{ki*} \rVert^2 }{ (d_{ki}^*)^2 }\right)\]

And:

\[d_{ki}^* = \max_{1 \leq p \leq n_n} \; { \lVert (\mathcal{X}_a)_{kn_{kip}^U*} - (\mathcal{X}_b)_{ki*} \rVert }\]
Returns:

\(\mathcal{Y} \in \mathbb{R}^{K \times m \times n_f}\)

static exponential_filter(Xa, Xb, Fin, NU)
\[y_{kij} = \left(\sum_{p=1}^{n_n}{g_{kip}}\right)^{-1} \sum_{p=1}^{n_n}{ g_{kip} f_{kn_{kip}^Dj} }\]

Where:

\[g_{kip} = \exp\left(\dfrac{ \lVert (\mathcal{X}_a)_{kn_{kip}^D*} - (\mathcal{X}_b)_{ki*} \rVert^2 }{ (d_{ki}^*)^2 }\right)\]

And:

\[d_{ki}^* = \max_{1 \leq p \leq n_n} \; { \lVert (\mathcal{X}_a)_{kn_{kip}^D*} - (\mathcal{X}_b)_{ki*} \rVert }\]
Returns:

\(\mathcal{Y} \in \mathbb{R}^{K \times R \times n_f}\)

static nearest_filter(Xa, Xb, Fin, NU)
\[y_{kij} = f_{kn_{ip^*}^Uj}\]

Where:

\[p^* = \operatorname*{argmin}_{1 \leq p \leq n_n} \; { \lVert (\mathcal{X}_a)_{kn_{ip}^U*} - (\mathcal{X}_b)_{ki*} } \rVert^2\]
Returns:

\(\mathcal{Y} \in \mathbb{R}^{K \times m \times n_f}\)

get_config()

Return necessary data to serialize the layer

classmethod from_config(config)

Use given config data to deserialize the layer