Skip to content

VarAggregation

VarAggregation(semi_grad: bool = False)

Bases: Aggregation

Feature-wise (population) variance of the elements of each set.

\[ \mathrm{var}(\mathcal{X}) = \mathrm{mean}(\{ \mathbf{x}_i^2 : \mathbf{x}_i \in \mathcal{X} \}) - \mathrm{mean}(\mathcal{X})^2. \]

Parameters:

Name Type Description Default
semi_grad bool

If True, no gradient flows through the computation of \(\mathrm{mean}(\mathcal{X}^2)\) (semi-gradient), which saves memory and compute in the backward pass. Default: False

False
Source code in mlx_graphs/nn/aggr/basic.py
def __init__(self, semi_grad: bool = False):
    super().__init__()
    self.semi_grad = semi_grad

from mlx_graphs.nn.aggr import VarAggregation · mlx_graphs/nn/aggr/basic.py