VariancePreservingAggregation
¶
Bases: Aggregation
The variance-preserving aggregation from the "GNN-VPA: A Variance-Preserving Aggregation Strategy for Graph Neural Networks" paper, as in PyG.
\[
\mathrm{vpa}(\mathcal{X}) = \frac{1}{\sqrt{|\mathcal{X}|}}
\sum_{\mathbf{x}_i \in \mathcal{X}} \mathbf{x}_i
\]
Example:
import mlx.core as mx
from mlx_graphs.nn.aggr import VariancePreservingAggregation
aggr = VariancePreservingAggregation()
x = mx.random.normal((6, 16))
index = mx.array([0, 0, 1, 1, 1, 2])
>>> aggr(x, index).shape
(3, 16)
from mlx_graphs.nn.aggr import VariancePreservingAggregation · mlx_graphs/nn/aggr/misc.py