Averaging Neural Operator Block#

class AVNOBlock(hidden_size=100, func=<class 'torch.nn.modules.activation.GELU'>)[source]

Bases: Module

The inner block of the Averaging Neural Operator.

The operator layer performs an affine transformation where the convolution is approximated with a local average. Given the input function \(v(x)\in\mathbb{R}^{\rm{emb}}\) the layer computes the operator update \(K(v)\) as:

\[K(v) = \sigma\left(Wv(x) + b + \frac{1}{|\mathcal{A}|}\int v(y)dy\right)\]

where:

  • \(\mathbb{R}^{\rm{emb}}\) is the embedding (hidden) size corresponding to the hidden_size object

  • \(\sigma\) is a non-linear activation, corresponding to the func object

  • \(W\in\mathbb{R}^{\rm{emb}\times\rm{emb}}\) is a tunable matrix.

  • \(b\in\mathbb{R}^{\rm{emb}}\) is a tunable bias.

See also

Original reference: Lanthaler S., Li, Z., Stuart, A. (2020). The Nonlocal Neural Operator: Universal Approximation. DOI: arXiv preprint arXiv:2304.13221.

Initialization of the AVNOBlock class.

Parameters:
  • hidden_size (int) – The size of the hidden layer. Defaults is 100.

  • func – The activation function. Default is torch.nn.GELU.

forward(x)[source]

Forward pass of the block. It performs a sum of local average and an affine transformation of the field.

Parameters:

x (torch.Tensor) – The input tensor for performing the computation.

Returns:

The output tensor.

Return type:

torch.Tensor