Averaging Neural Operator#

class AveragingNeuralOperator(lifting_net, projecting_net, field_indices, coordinates_indices, n_layers=4, func=<class 'torch.nn.modules.activation.GELU'>)[source]#

Bases: KernelNeuralOperator

Implementation of Averaging Neural Operator.

Averaging Neural Operator is a general architecture for learning Operators. Unlike traditional machine learning methods AveragingNeuralOperator is designed to map entire functions to other functions. It can be trained with Supervised learning strategies. AveragingNeuralOperator does convolution by performing a field average.

See also

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

Parameters:
  • lifting_net (torch.nn.Module) – The neural network for lifting the input. It must take as input the input field and the coordinates at which the input field is avaluated. The output of the lifting net is chosen as embedding dimension of the problem

  • projecting_net (torch.nn.Module) – The neural network for projecting the output. It must take as input the embedding dimension (output of the lifting_net) plus the dimension of the coordinates.

  • field_indices (list[str]) – the label of the fields in the input tensor.

  • coordinates_indices (list[str]) – the label of the coordinates in the input tensor.

  • n_layers (int) – number of hidden layers. Default is 4.

  • func (torch.nn.Module) – the activation function to use, default to torch.nn.GELU.

forward(x)[source]#

Forward computation for Averaging Neural Operator. It performs a lifting of the input by the lifting_net. Then different layers of Averaging Neural Operator Blocks are applied. Finally the output is projected to the final dimensionality by the projecting_net.

Parameters:

x (torch.Tensor) – The input tensor for fourier block, depending on dimension in the initialization. It expects a tensor \(B \times N \times D\), where \(B\) is the batch_size, \(N\) the number of points in the mesh, \(D\) the dimension of the problem, i.e. the sum of len(coordinates_indices)+len(field_indices).

Returns:

The output tensor obtained from Average Neural Operator.

Return type:

torch.Tensor