SplineConv
¶
SplineConv(
node_features_dim: Union[int, Tuple[int, int]],
out_features_dim: int,
dim: int,
kernel_size: Union[int, List[int]],
is_open_spline: Union[bool, List[bool]] = True,
degree: int = 1,
aggr: str = "mean",
root_weight: bool = True,
bias: bool = True,
**kwargs,
)
Bases: MessagePassing
The spline-based convolutional operator from the "SplineCNN: Fast Geometric Deep Learning with Continuous B-Spline Kernels" paper.
where \(h_{\mathbf{\Theta}}\) is a kernel function defined over the
weighted B-spline tensor product basis of the pseudo-coordinates
\(\mathbf{e}_{i,j} \in [0, 1]^D\) (edge_features, e.g. from the
Cartesian transform).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
Union[int, Tuple[int, int]]
|
Size of the input features, or a |
required |
out_features_dim
|
int
|
Size of the output features. |
required |
dim
|
int
|
Pseudo-coordinate dimensionality \(D\). |
required |
kernel_size
|
Union[int, List[int]]
|
Size of the convolving kernel in each dimension. |
required |
is_open_spline
|
Union[bool, List[bool]]
|
Whether to use open ( |
True
|
degree
|
int
|
B-spline basis degree (1, 2 or 3). Default: |
1
|
aggr
|
str
|
Aggregation of the messages. Default: |
'mean'
|
root_weight
|
bool
|
Whether to add the transformed root node features.
Default: |
True
|
bias
|
bool
|
Whether to add a bias. Default: |
True
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
from mlx_graphs.nn import SplineConv
edge_index = mx.array([[0, 1, 2, 3], [1, 0, 3, 2]])
x = mx.random.normal((4, 16))
pseudo = mx.random.uniform(shape=(4, 2))
conv = SplineConv(16, 32, dim=2, kernel_size=5)
>>> conv(edge_index, x, pseudo).shape
(4, 32)
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of SplineConv. |
Source code in mlx_graphs/nn/conv/spline_conv.py
__call__
¶
__call__(
edge_index: array,
node_features: Union[array, Tuple[array, array]],
edge_features: array,
) -> array
Computes the forward pass of SplineConv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Edges of shape |
required |
node_features
|
Union[array, Tuple[array, array]]
|
Node features, or a |
required |
edge_features
|
array
|
Pseudo-coordinates of shape |
required |
Returns:
| Type | Description |
|---|---|
array
|
The features of the destination nodes. |
Source code in mlx_graphs/nn/conv/spline_conv.py
from mlx_graphs.nn import SplineConv · mlx_graphs/nn/conv/spline_conv.py