TAGConv
¶
TAGConv(
node_features_dim: int,
out_features_dim: int,
K: int = 3,
bias: bool = True,
normalize: bool = True,
**kwargs,
)
Bases: MessagePassing
Topology adaptive graph convolution layer from "Topology Adaptive Graph Convolutional Networks" paper.
where \(\mathbf{A}\) is the (weighted) adjacency matrix and \(\mathbf{D}\) its diagonal degree matrix. No self-loops are added.
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 |
K
|
int
|
Number of hops \(K\) |
3
|
bias
|
bool
|
Whether to add a bias to the output |
True
|
normalize
|
bool
|
Whether to apply the symmetric normalization. If |
True
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
from mlx_graphs.nn import TAGConv
edge_index = mx.array([[0, 1, 2, 3, 4], [0, 0, 1, 1, 3]])
node_features = mx.ones((5, 16))
conv = TAGConv(16, 32, K=3)
h = conv(edge_index, node_features)
>>> h.shape
(5, 32)
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of TAGConv. |
Source code in mlx_graphs/nn/conv/tag_conv.py
__call__
¶
__call__(
edge_index: array,
node_features: array,
edge_weights: Optional[array] = None,
) -> array
Computes the forward pass of TAGConv.
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 scalar weight per edge, of shape |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The computed node embeddings |
Source code in mlx_graphs/nn/conv/tag_conv.py
from mlx_graphs.nn import TAGConv · mlx_graphs/nn/conv/tag_conv.py