MixHopConv
¶
MixHopConv(
node_features_dim: int,
out_features_dim: int,
powers: Optional[List[int]] = None,
add_self_loops: bool = True,
bias: bool = True,
**kwargs,
)
Bases: MessagePassing
The Mix-Hop graph convolutional operator from the "MixHop: Higher-Order Graph Convolutional Architectures via Sparsified Neighborhood Mixing" paper.
where \(\mathbf{\hat{A}} = \mathbf{A} + \mathbf{I}\) denotes the
adjacency matrix with inserted self-loops and
\(\hat{D}_{ii} = \sum_{j=0} \hat{A}_{ij}\) its diagonal degree matrix.
The output concatenates one block of out_features_dim features per
power, so it has len(powers) * out_features_dim features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
int
|
Size of input node features |
required |
out_features_dim
|
int
|
Size of the output of every power |
required |
powers
|
Optional[List[int]]
|
Powers of the adjacency matrix to use. Default: |
None
|
add_self_loops
|
bool
|
Whether to add self-loops to the input graph.
Default: |
True
|
bias
|
bool
|
Whether to add a learnable bias to the output. Default: |
True
|
Example:
import mlx.core as mx
from mlx_graphs.nn import MixHopConv
conv = MixHopConv(16, 32, powers=[0, 1, 2])
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, 96)
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of MixHopConv. |
Source code in mlx_graphs/nn/conv/mixhop_conv.py
__call__
¶
__call__(
edge_index: array,
node_features: array,
edge_weights: Optional[array] = None,
) -> array
Computes the forward pass of MixHopConv.
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 weight of each edge. Default: |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The computed node embeddings, of shape |
array
|
|
Source code in mlx_graphs/nn/conv/mixhop_conv.py
from mlx_graphs.nn import MixHopConv · mlx_graphs/nn/conv/mixhop_conv.py