Skip to content

max_pool_x

max_pool_x(
    cluster: array,
    x: array,
    batch: array,
    batch_size: Optional[int] = None,
    size: Optional[int] = None,
) -> Tuple[array, Optional[array]]

Takes the feature-wise maximum of the nodes of each cluster.

Parameters:

Name Type Description Default
cluster array

Cluster of each node, of shape [N].

required
x array

Node features, of shape [N, F].

required
batch array

Graph of each node, of shape [N].

required
batch_size Optional[int]

The number of graphs (only used with size). Default: None (inferred from batch).

None
size Optional[int]

If given, the maximum number of clusters per graph: the output then has batch_size * size rows indexed by cluster directly, and no batch vector is returned. Default: None

None

Returns:

Type Description
A tuple `(x, batch)`

the features of each cluster, in increasing

Optional[array]

order of cluster id, and the graph of each cluster (None when

Tuple[array, Optional[array]]

size is given).

Source code in mlx_graphs/nn/pooling/cluster_pooling.py
def max_pool_x(
    cluster: mx.array,
    x: mx.array,
    batch: mx.array,
    batch_size: Optional[int] = None,
    size: Optional[int] = None,
) -> Tuple[mx.array, Optional[mx.array]]:
    r"""Takes the feature-wise maximum of the nodes of each cluster.

    Args:
        cluster: Cluster of each node, of shape ``[N]``.
        x: Node features, of shape ``[N, F]``.
        batch: Graph of each node, of shape ``[N]``.
        batch_size: The number of graphs (only used with ``size``). Default:
            ``None`` (inferred from ``batch``).
        size: If given, the maximum number of clusters per graph: the output
            then has ``batch_size * size`` rows indexed by ``cluster`` directly,
            and no batch vector is returned. Default: ``None``

    Returns:
        A tuple ``(x, batch)``: the features of each cluster, in increasing
        order of cluster id, and the graph of each cluster (``None`` when
        ``size`` is given).
    """
    return _pool_x(cluster, x, batch, "max", batch_size, size)

from mlx_graphs.nn import max_pool_x · mlx_graphs/nn/pooling/cluster_pooling.py