DeepSetsAggregation
¶
DeepSetsAggregation(
local_nn: Optional[Callable[[array], array]] = None,
global_nn: Optional[Callable[[array], array]] = None,
)
Bases: Aggregation
Deep Sets aggregation: the elements are transformed by a network \(\phi_{\mathbf{\Theta}}\), summed, and the sum is transformed by a network \(\rho_{\mathbf{\Theta}}\), as in "Graph Neural Networks with Adaptive Readouts" paper.
\[
\mathrm{deepsets}(\mathcal{X}) = \rho_{\mathbf{\Theta}} \left(
\sum_{\mathbf{x}_i \in \mathcal{X}} \phi_{\mathbf{\Theta}}
(\mathbf{x}_i) \right)
\]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_nn
|
Optional[Callable[[array], array]]
|
Network \(\phi_{\mathbf{\Theta}}\) applied to every
element (e.g. an |
None
|
global_nn
|
Optional[Callable[[array], array]]
|
Network \(\rho_{\mathbf{\Theta}}\) applied to every
sum. Default: |
None
|
Example:
import mlx.core as mx
from mlx_graphs.nn import MLP
from mlx_graphs.nn.aggr import DeepSetsAggregation
aggr = DeepSetsAggregation(MLP([16, 32, 32]), MLP([32, 32, 8]))
x = mx.random.normal((6, 16))
index = mx.array([0, 0, 1, 1, 1, 2])
>>> aggr(x, index).shape
(3, 8)
Source code in mlx_graphs/nn/aggr/deep_sets.py
from mlx_graphs.nn.aggr import DeepSetsAggregation · mlx_graphs/nn/aggr/deep_sets.py