GatedGraphConv
¶
GatedGraphConv(
out_features_dim: int,
num_layers: int,
aggr: str = "add",
bias: bool = True,
**kwargs,
)
Bases: MessagePassing
Gated graph convolution layer from the "Gated Graph Sequence Neural Networks" paper.
up to \(\mathbf{h}_i^{(L)}\), where \(e_{j,i}\) is the weight of the
edge from node \(j\) to node \(i\) (1 if no weights are given).
Input features smaller than out_features_dim are zero-padded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_features_dim
|
int
|
Size of output node embeddings (input features must not be larger) |
required |
num_layers
|
int
|
Number of message passing steps \(L\) |
required |
aggr
|
str
|
Aggregation \(\bigoplus\). Default: |
'add'
|
bias
|
bool
|
Whether the GRU cell uses biases. Default: |
True
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
from mlx_graphs.nn import GatedGraphConv
edge_index = mx.array([[0, 1, 2, 3, 4], [1, 0, 3, 2, 0]])
node_features = mx.random.normal((5, 16))
conv = GatedGraphConv(32, num_layers=3)
h = conv(edge_index, node_features)
>>> h.shape
(5, 32)
References
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of GatedGraphConv. |
Source code in mlx_graphs/nn/conv/gated_graph_conv.py
__call__
¶
__call__(
edge_index: array,
node_features: array,
edge_weights: Optional[array] = None,
) -> array
Computes the forward pass of GatedGraphConv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Input edge index of shape |
required |
node_features
|
array
|
Input node features, with at most
|
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/gated_graph_conv.py
from mlx_graphs.nn import GatedGraphConv · mlx_graphs/nn/conv/gated_graph_conv.py