max_pool
¶
Pools and coarsens a graph given by a clustering, taking the
feature-wise maximum of the nodes of each cluster (as PyG's max_pool).
The positions are averaged.
Edges are mapped onto the clusters of their nodes; self-loops are removed
and duplicate edges merged (their edge_features are summed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cluster
|
array
|
Cluster of each node, of shape |
required |
data
|
GraphData
|
The graph (or |
required |
transform
|
Optional[Callable]
|
A function/transform applied to the coarsened graph.
Default: |
None
|
Returns:
| Type | Description |
|---|---|
GraphData
|
The coarsened graph, with one node per cluster (in increasing order of |
GraphData
|
cluster id), the average |
GraphData
|
|
Example:
from mlx_graphs.nn import max_pool
from mlx_graphs.utils import voxel_grid
cluster = voxel_grid(batch.pos, size=0.2, batch=batch.batch_indices)
coarse = max_pool(cluster, batch)
Source code in mlx_graphs/nn/pooling/cluster_pooling.py
from mlx_graphs.nn import max_pool · mlx_graphs/nn/pooling/cluster_pooling.py