Skip to content

Commit 2edf4ea

Browse files
fix doc model part 1
1 parent ada4f53 commit 2edf4ea

10 files changed

+682
-439
lines changed

pina/model/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Module containing the neural network models.
2+
Module for the Neural model classes.
33
"""
44

55
__all__ = [

pina/model/average_neural_operator.py

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Module Averaging Neural Operator."""
1+
"""Module for the Averaging Neural Operator model class."""
22

33
import torch
44
from torch import nn
@@ -9,19 +9,17 @@
99

1010
class AveragingNeuralOperator(KernelNeuralOperator):
1111
"""
12-
Implementation of Averaging Neural Operator.
12+
Averaging Neural Operator model class.
1313
14-
Averaging Neural Operator is a general architecture for
15-
learning Operators. Unlike traditional machine learning methods
16-
AveragingNeuralOperator is designed to map entire functions
17-
to other functions. It can be trained with Supervised learning strategies.
18-
AveragingNeuralOperator does convolution by performing a field average.
14+
The Averaging Neural Operator is a general architecture for learning
15+
operators, which map functions to functions. It can be trained both with
16+
Supervised and Physics-Informed learning strategies. The Averaging Neural
17+
Operator performs convolution by means of a field average.
1918
2019
.. seealso::
2120
22-
**Original reference**: Lanthaler S. Li, Z., Kovachki,
23-
Stuart, A. (2020). *The Nonlocal Neural Operator:
24-
Universal Approximation*.
21+
**Original reference**: Lanthaler S., Li, Z., Stuart, A. (2020).
22+
*The Nonlocal Neural Operator: Universal Approximation*.
2523
DOI: `arXiv preprint arXiv:2304.13221.
2624
<https://arxiv.org/abs/2304.13221>`_
2725
"""
@@ -36,21 +34,26 @@ def __init__(
3634
func=nn.GELU,
3735
):
3836
"""
39-
:param torch.nn.Module lifting_net: The neural network for lifting
40-
the input. It must take as input the input field and the coordinates
41-
at which the input field is avaluated. The output of the lifting
42-
net is chosen as embedding dimension of the problem
43-
:param torch.nn.Module projecting_net: The neural network for
44-
projecting the output. It must take as input the embedding dimension
45-
(output of the ``lifting_net``) plus the dimension
46-
of the coordinates.
47-
:param list[str] field_indices: the label of the fields
48-
in the input tensor.
49-
:param list[str] coordinates_indices: the label of the
50-
coordinates in the input tensor.
51-
:param int n_layers: number of hidden layers. Default is 4.
52-
:param torch.nn.Module func: the activation function to use,
53-
default to torch.nn.GELU.
37+
Initialization of the :class:`AveragingNeuralOperator` class.
38+
39+
:param torch.nn.Module lifting_net: The lifting neural network mapping
40+
the input to its hidden dimension. It must take as input the input
41+
field and the coordinates at which the input field is evaluated.
42+
:param torch.nn.Module projecting_net: The projection neural network
43+
mapping the hidden representation to the output function. It must
44+
take as input the embedding dimension plus the dimension of the
45+
coordinates.
46+
:param list[str] field_indices: The labels of the fields in the input
47+
tensor.
48+
:param list[str] coordinates_indices: The labels of the coordinates in
49+
the input tensor.
50+
:param int n_layers: The number of hidden layers. Default is ``4``.
51+
:param torch.nn.Module func: The activation function to use.
52+
Default is :class:`torch.nn.GELU`.
53+
:raises ValueError: If the input dimension does not match with the
54+
labels of the fields and coordinates.
55+
:raises ValueError: If the input dimension of the projecting network
56+
does not match with the hidden dimension of the lifting network.
5457
"""
5558

5659
# check consistency
@@ -93,19 +96,20 @@ def __init__(
9396

9497
def forward(self, x):
9598
r"""
96-
Forward computation for Averaging Neural Operator. It performs a
97-
lifting of the input by the ``lifting_net``. Then different layers
98-
of Averaging Neural Operator Blocks are applied.
99-
Finally the output is projected to the final dimensionality
100-
by the ``projecting_net``.
101-
102-
:param torch.Tensor x: The input tensor for fourier block,
103-
depending on ``dimension`` in the initialization. It expects
104-
a tensor :math:`B \times N \times D`,
105-
where :math:`B` is the batch_size, :math:`N` the number of points
106-
in the mesh, :math:`D` the dimension of the problem, i.e. the sum
107-
of ``len(coordinates_indices)+len(field_indices)``.
108-
:return: The output tensor obtained from Average Neural Operator.
99+
Forward pass for the :class:`AveragingNeuralOperator` model.
100+
101+
The ``lifting_net`` maps the input to the hidden dimension.
102+
Then, several layers of
103+
:class:`~pina.model.block.average_neural_operator_block.AVNOBlock` are
104+
applied. Finally, the ``projection_net`` maps the hidden representation
105+
to the output function.
106+
107+
:param LabelTensor x: The input tensor for performing the computation.
108+
It expects a tensor :math:`B \times N \times D`, where :math:`B` is
109+
the batch_size, :math:`N` the number of points in the mesh,
110+
:math:`D` the dimension of the problem, i.e. the sum
111+
of ``len(coordinates_indices)`` and ``len(field_indices)``.
112+
:return: The output tensor.
109113
:rtype: torch.Tensor
110114
"""
111115
points_tmp = x.extract(self.coordinates_indices)

0 commit comments

Comments
 (0)