ClusterGCNConv
¶
ClusterGCNConv(
node_features_dim: int,
out_features_dim: int,
diag_lambda: float = 0.0,
add_self_loops: bool = True,
bias: bool = True,
**kwargs,
)
Bases: MessagePassing
Graph convolution layer from the "Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks" paper.
where \(\mathbf{\hat{A}} = {(\mathbf{D} + \mathbf{I})}^{-1} (\mathbf{A} + \mathbf{I})\) is the row-normalized adjacency matrix with self-loops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
int
|
Size of input node features |
required |
out_features_dim
|
int
|
Size of output node embeddings |
required |
diag_lambda
|
float
|
Diagonal enhancement value \(\lambda\). Default: |
0.0
|
add_self_loops
|
bool
|
Whether to replace the self-loops of the graph by one
self-loop per node. Default: |
True
|
bias
|
bool
|
Whether to add a bias to the output. Default: |
True
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
from mlx_graphs.nn import ClusterGCNConv
edge_index = mx.array([[0, 1, 2, 3, 4], [1, 0, 3, 2, 0]])
node_features = mx.random.normal((5, 16))
conv = ClusterGCNConv(16, 32, diag_lambda=1.0)
h = conv(edge_index, node_features)
>>> h.shape
(5, 32)
References
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of ClusterGCNConv. |
Source code in mlx_graphs/nn/conv/cluster_gcn_conv.py
__call__
¶
Computes the forward pass of ClusterGCNConv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Input edge index of shape |
required |
node_features
|
array
|
Input node features |
required |
Returns:
| Type | Description |
|---|---|
array
|
The computed node embeddings |
Source code in mlx_graphs/nn/conv/cluster_gcn_conv.py
from mlx_graphs.nn import ClusterGCNConv · mlx_graphs/nn/conv/cluster_gcn_conv.py