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
Averaging Neural Operator model class.
The Averaging Neural Operator is a general architecture for learning operators, which map functions to functions. It can be trained both with Supervised and Physics-Informed learning strategies. The Averaging Neural Operator performs convolution by means of a field average.
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
AveragingNeuralOperator
class.- Parameters:
lifting_net (torch.nn.Module) – The lifting neural network mapping the input to its hidden dimension. It must take as input the input field and the coordinates at which the input field is evaluated.
projecting_net (torch.nn.Module) – The projection neural network mapping the hidden representation to the output function. It must take as input the embedding dimension plus the dimension of the coordinates.
field_indices (list[str]) – The labels of the fields in the input tensor.
coordinates_indices (list[str]) – The labels of the coordinates in the input tensor.
n_layers (int) – The number of hidden layers. Default is
4
.func (torch.nn.Module) – The activation function to use. Default is
torch.nn.GELU
.
- Raises:
ValueError – If the input dimension does not match with the labels of the fields and coordinates.
ValueError – If the input dimension of the projecting network does not match with the hidden dimension of the lifting network.
- forward(x)[source]#
Forward pass for the
AveragingNeuralOperator
model.The
lifting_net
maps the input to the hidden dimension. Then, several layers ofAVNOBlock
are applied. Finally, theprojection_net
maps the hidden representation to the output function.- Parameters:
x (LabelTensor) – The input tensor for performing the computation. 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)
andlen(field_indices)
.- Returns:
The output tensor.
- Return type: