EdgeConv
¶
Bases: MessagePassing
Edge convolution layer from "Dynamic Graph CNN for Learning on Point Clouds" paper.
where \(\mathbf{x}_i\) represents the input features of node \(i\),
\([\cdot, \cdot]\) is the concatenation, \(\text{MLP}\) denotes a custom
neural network provided by the user and \(\bigoplus\) denotes the aggregation
function, set by default to max. Nodes without incoming edges get a zero
embedding.
The layer also works on bipartite graphs: pass node_features as a
(src_features, dst_features) tuple (both with the same feature size). The
output has one row per destination node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mlp
|
Module
|
Callable |
required |
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
import mlx.nn as nn
from mlx_graphs.nn.conv.edge_conv import EdgeConv
mlp = nn.Sequential(
nn.Linear(2 * 16, 32),
nn.ReLU(),
nn.Linear(32, 32),
)
conv = EdgeConv(mlp)
edge_index = mx.array([[0, 1, 2, 3, 4], [0, 0, 1, 1, 3]])
node_features = mx.random.uniform(low=0, high=1, shape=(5, 16))
h = conv(edge_index, node_features)
>>> h.shape
(5, 32)
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of EdgeConv. |
message |
Computes |
Source code in mlx_graphs/nn/conv/edge_conv.py
__call__
¶
Computes the forward pass of EdgeConv.
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 |
Returns:
| Type | Description |
|---|---|
array
|
The computed node embeddings, one row per destination node |
Source code in mlx_graphs/nn/conv/edge_conv.py
message
¶
Computes mlp([x_i, x_j - x_i]) for every edge j -> i.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_features
|
array
|
Features of the source nodes \(\mathbf{x}_j\) |
required |
dst_features
|
array
|
Features of the destination nodes \(\mathbf{x}_i\) |
required |
Returns:
| Type | Description |
|---|---|
array
|
The messages, shape |
Source code in mlx_graphs/nn/conv/edge_conv.py
from mlx_graphs.nn import EdgeConv · mlx_graphs/nn/conv/edge_conv.py