DeepGCNLayer
¶
DeepGCNLayer(
conv: Optional[Module] = None,
norm: Optional[Module] = None,
act: Optional[Callable[[array], array]] = None,
block: Literal["res+", "res", "dense", "plain"] = "res+",
dropout: float = 0.0,
ckpt_grad: bool = False,
)
Bases: Module
The skip connection operations from the "DeepGCNs: Can GCNs Go as Deep as CNNs?" and "All You Need to Train Deeper GCNs" papers.
- Res+ (
"res+"): Normalization \(\to\) Activation \(\to\) Dropout \(\to\) GraphConv \(\to\) Res - Res (
"res") / Dense ("dense") / Plain ("plain"): GraphConv \(\to\) Normalization \(\to\) Activation \(\to\) Res/Dense/Plain \(\to\) Dropout
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conv
|
Optional[Module]
|
The graph convolution, called as |
None
|
norm
|
Optional[Module]
|
The normalization layer. Default: |
None
|
act
|
Optional[Callable[[array], array]]
|
The activation function. Default: |
None
|
block
|
Literal['res+', 'res', 'dense', 'plain']
|
The skip connection: |
'res+'
|
dropout
|
float
|
Dropout probability. Default: |
0.0
|
ckpt_grad
|
bool
|
If |
False
|
Example:
import mlx.nn as nn
from mlx_graphs.nn import DeepGCNLayer, GCNConv
layers = [
DeepGCNLayer(
GCNConv(64, 64),
norm=nn.LayerNorm(64),
act=nn.relu,
block="res+",
dropout=0.1,
)
for _ in range(28)
]
x = layers[0].conv(edge_index, x)
for layer in layers[1:]:
x = layer(edge_index, x)
References
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of the block. |
Source code in mlx_graphs/nn/models/deepgcn.py
__call__
¶
Computes the forward pass of the block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Input edge index of shape |
required |
node_features
|
array
|
Input node features |
required |
*args
|
Any
|
Additional arguments of the convolution |
()
|
**kwargs
|
Any
|
Additional keyword arguments of the convolution |
{}
|
Returns:
| Type | Description |
|---|---|
array
|
The output node embeddings. |
Source code in mlx_graphs/nn/models/deepgcn.py
from mlx_graphs.nn import DeepGCNLayer · mlx_graphs/nn/models/deepgcn.py