ARMAConv
¶
ARMAConv(
node_features_dim: int,
out_features_dim: int,
num_stacks: int = 1,
num_layers: int = 1,
shared_weights: bool = False,
act: Optional[Callable[[array], array]] = relu,
dropout: float = 0.0,
bias: bool = True,
**kwargs,
)
Bases: MessagePassing
ARMA graph convolution layer from the "Graph Neural Networks with Convolutional ARMA Filters" paper.
where each of the \(K\) stacks is computed recursively by
with \(\mathbf{\hat{L}} = \mathbf{I} - \mathbf{L} = \mathbf{D}^{-1/2} \mathbf{A} \mathbf{D}^{-1/2}\) (no self-loops are added) and \(\mathbf{X}_k^{(0)} = \mathbf{X}\).
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 |
num_stacks
|
int
|
Number of parallel stacks \(K\). Default: |
1
|
num_layers
|
int
|
Number of layers \(T\) of each stack. Default: |
1
|
shared_weights
|
bool
|
If |
False
|
act
|
Optional[Callable[[array], array]]
|
Activation function \(\sigma\) applied after each layer, or
|
relu
|
dropout
|
float
|
Dropout probability of the skip connection
\(\mathbf{X}^{(0)}\), applied in training mode. Default: |
0.0
|
bias
|
bool
|
Whether to add a bias after each layer. Default: |
True
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
from mlx_graphs.nn import ARMAConv
edge_index = mx.array([[0, 1, 2, 3, 4], [1, 0, 3, 2, 0]])
node_features = mx.random.normal((5, 16))
conv = ARMAConv(16, 32, num_stacks=2, num_layers=3)
h = conv(edge_index, node_features)
>>> h.shape
(5, 32)
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of ARMAConv. |
Source code in mlx_graphs/nn/conv/arma_conv.py
__call__
¶
__call__(
edge_index: array,
node_features: array,
edge_weights: Optional[array] = None,
) -> array
Computes the forward pass of ARMAConv.
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/arma_conv.py
from mlx_graphs.nn import ARMAConv · mlx_graphs/nn/conv/arma_conv.py