GCN
¶
GCN(
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: BasicGNN
Graph Convolutional Network from "Semi-Supervised Classification with Graph Convolutional Networks", a stack
of GCNConv layers.
Self-loops are added by default, as in the paper; pass
add_self_loops=False to disable them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
Union[int, Tuple[int, int]]
|
Size of the input node features. |
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. Default: |
None
|
dropout
|
float
|
Dropout probability. Default: |
0.0
|
act
|
Activation
|
Activation between layers. Default: |
'relu'
|
norm
|
Normalization
|
Normalization between layers. Default: |
None
|
jk
|
Optional[Literal['cat', 'max', 'lstm']]
|
Jumping Knowledge mode. Default: |
None
|
**kwargs
|
Any
|
Additional arguments of |
{}
|
Example:
from mlx_graphs.nn import GCN
model = GCN(
dataset.num_node_features,
64,
num_layers=2,
out_features_dim=dataset.num_node_classes,
dropout=0.5,
)
logits = model(graph.edge_index, graph.node_features)
Source code in mlx_graphs/nn/models/basic_gnn.py
from mlx_graphs.nn import GCN · mlx_graphs/nn/models/basic_gnn.py