BasicGNN
¶
BasicGNN(
node_features_dim: Union[int, Tuple[int, int]],
hidden_features_dim: int,
num_layers: int,
out_features_dim: Optional[int] = None,
dropout: float = 0.0,
act: Activation = "relu",
norm: Normalization = None,
jk: Optional[Literal["cat", "max", "lstm"]] = None,
**kwargs: Any,
)
Bases: Module
Base class of the ready-to-use GNN models.
Stacks num_layers convolution layers with an activation, an optional
normalization and dropout in between. Subclasses only choose the
convolution layer by implementing init_conv().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
Union[int, Tuple[int, int]]
|
Size of the input node features, or a
|
required |
hidden_features_dim
|
int
|
Size of the hidden node embeddings. |
required |
num_layers
|
int
|
Number of message passing layers. |
required |
out_features_dim
|
Optional[int]
|
Size of the output. If |
None
|
dropout
|
float
|
Dropout probability. Default: |
0.0
|
act
|
Activation
|
Activation between layers: a name ( |
'relu'
|
norm
|
Normalization
|
Normalization between layers: |
None
|
jk
|
Optional[Literal['cat', 'max', 'lstm']]
|
Jumping Knowledge mode combining the embeddings of all layers:
|
None
|
**kwargs
|
Any
|
Additional arguments of the convolution layer. |
{}
|
Methods:
| Name | Description |
|---|---|
init_conv |
Builds one convolution layer. Implemented by subclasses. |
__call__ |
Computes the node embeddings (or predictions). |
Source code in mlx_graphs/nn/models/basic_gnn.py
init_conv
¶
Builds one convolution layer. Implemented by subclasses.
__call__
¶
__call__(
edge_index: array,
node_features: array,
edge_weights: Optional[array] = None,
edge_features: Optional[array] = None,
) -> array
Computes the node embeddings (or predictions).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Input edge index of shape |
required |
node_features
|
array
|
Input node features |
required |
edge_weights
|
Optional[array]
|
Optional weight of each edge, for models whose convolution supports it. |
None
|
edge_features
|
Optional[array]
|
Optional features of each edge, for models whose convolution supports it. |
None
|
Returns:
| Type | Description |
|---|---|
array
|
An array of shape |
Source code in mlx_graphs/nn/models/basic_gnn.py
from mlx_graphs.nn import BasicGNN · mlx_graphs/nn/models/basic_gnn.py