GraphNormalization
¶
Bases: Module
Applies graph normalization over individual graphs as described in the "GraphNorm: A Principled Approach to Accelerating Graph Neural Network Training" paper.
where \(\alpha\) denotes parameters that learn how much information
to keep in the mean. The statistics are computed per graph and per
feature. Also available as GraphNorm, its PyG name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
int
|
Size of the input node features. |
required |
eps
|
float
|
A value added to the denominator for numerical stability.
Default: |
1e-05
|
Example:
import mlx.core as mx
from mlx_graphs.nn import GraphNormalization
norm = GraphNormalization(16)
node_features = mx.random.normal((5, 16))
batch_indices = mx.array([0, 0, 0, 1, 1])
>>> norm(node_features, batch_indices).shape
(5, 16)
Methods:
| Name | Description |
|---|---|
__call__ |
Normalizes the node features of each graph. |
Source code in mlx_graphs/nn/norm/graph_norm.py
__call__
¶
__call__(
node_features: array,
batch_indices: Optional[array] = None,
num_graphs: Optional[int] = None,
) -> array
Normalizes the node features of each graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features
|
array
|
Node features of shape |
required |
batch_indices
|
Optional[array]
|
Graph of each node, of shape |
None
|
num_graphs
|
Optional[int]
|
Number of graphs. Default: |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The normalized node features. |
Source code in mlx_graphs/nn/norm/graph_norm.py
from mlx_graphs.nn import GraphNormalization · mlx_graphs/nn/norm/graph_norm.py