Graph Neural Operator Block#
- class GNOBlock(width, edges_features, n_layers=2, layers=None, inner_size=None, internal_func=None, external_func=None)[source]
Bases:
MessagePassing
The inner block of the Graph Neural Operator, based on Message Passing.
Initialization of the
GNOBlock
class.- Parameters:
width (int) – The width of the kernel.
edge_features (int) – The number of edge features.
n_layers (int) – The number of kernel layers. Default is
2
.layers (list[int] | tuple[int]) – A list specifying the number of neurons for each layer of the neural network. If not
None
, it overrides theinner_size
andn_layers``parameters. Default is ``None
.inner_size (int) – The size of the inner layer. Default is
None
.internal_func (torch.nn.Module) – The activation function applied to the output of each layer. If
None
, it uses thetorch.nn.Tanh
activation. Default isNone
.external_func (torch.nn.Module) – The activation function applied to the output of the block. If
None
, it uses thetorch.nn.Tanh
. activation. Default isNone
.
- message_and_aggregate(edge_index, x, edge_attr)[source]
Combine messages and perform aggregation.
- Parameters:
edge_index (torch.Tensor) – The edge index.
x (torch.Tensor) – The node feature matrix.
edge_attr (torch.Tensor) – The edge features.
- Returns:
The aggregated messages.
- Return type:
- edge_update(edge_attr)[source]
Update edge features.
- Parameters:
edge_attr (torch.Tensor) – The edge features.
- Returns:
The updated edge features.
- Return type:
- update(aggr_out, x)[source]
Update node features.
- Parameters:
aggr_out (torch.Tensor) – The aggregated messages.
x (torch.Tensor) – The node feature matrix.
- Returns:
The updated node features.
- Return type:
- forward(x, edge_index, edge_attr)[source]
Forward pass of the block.
- Parameters:
x (torch.Tensor) – The node features.
edge_index (torch.Tensor) – The edge indeces.
edge_attr (torch.Tensor) – The edge features.
- Returns:
The updated node features.
- Return type: