GINEConv
¶
GINEConv(
mlp: Module,
eps: float = 0.0,
learn_eps: bool = False,
edge_features_dim: Optional[int] = None,
node_features_dim: Optional[int] = None,
**kwargs,
)
Bases: GINConv
Graph Isomorphism Network convolution with edge features, from the "Strategies for Pre-training Graph Neural Networks" paper.
where \(\mathbf{e}_{j,i}\) are the features of the edge from node
\(j\) to node \(i\). If edge_features_dim is set, edge features
are first projected with a linear layer onto the size of the node features;
otherwise both must have the same size.
This is GINConv with edge features made mandatory, mirroring PyG's
GINEConv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mlp
|
Module
|
Callable |
required |
eps
|
float
|
Initial value of the \(\epsilon\) term. Default: |
0.0
|
learn_eps
|
bool
|
Whether to learn \(\epsilon\) or not. Default |
False
|
edge_features_dim
|
Optional[int]
|
Size of the edge features. If set, edge features are
projected onto the size of the node features. Default: |
None
|
node_features_dim
|
Optional[int]
|
Size of the node features, only used when
|
None
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
import mlx.nn as nn
from mlx_graphs.nn import GINEConv
mlp = nn.Sequential(nn.Linear(16, 32), nn.ReLU(), nn.Linear(32, 32))
conv = GINEConv(mlp, edge_features_dim=4)
edge_index = mx.array([[0, 1, 2, 3, 4], [0, 0, 1, 1, 3]])
node_features = mx.random.normal((5, 16))
edge_features = mx.random.normal((5, 4))
h = conv(edge_index, node_features, edge_features)
>>> h.shape
(5, 32)
References
[1] Hu et al. Strategies for Pre-training Graph Neural Networks.
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of GINEConv. |
Source code in mlx_graphs/nn/conv/gine_conv.py
__call__
¶
__call__(
edge_index: array,
node_features: Union[array, Tuple[array, array]],
edge_features: array,
) -> array
Computes the forward pass of GINEConv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Input edge index of shape |
required |
node_features
|
Union[array, Tuple[array, array]]
|
Input node features, or a |
required |
edge_features
|
array
|
Edge features of shape |
required |
Returns:
| Type | Description |
|---|---|
array
|
The computed node embeddings |
Source code in mlx_graphs/nn/conv/gine_conv.py
from mlx_graphs.nn import GINEConv · mlx_graphs/nn/conv/gine_conv.py