global_mean_pool
¶
global_mean_pool(
node_features: array,
batch_indices: Optional[array] = None,
num_graphs: Optional[int] = None,
) -> array
Takes the feature-wise mean value along all node features to obtain a global graph-level representation.
If batch_indices is provided, applies pooling for each graph in the batch.
The returned shape is (1, node_features_dim) if batch_indices is None, otherise
the shape is (num_batches, node_features_dim).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features
|
array
|
Node features array. |
required |
batch_indices
|
Optional[array]
|
Batch array of shape (node_features.shape[0]), indicating for each node its batch index. |
None
|
num_graphs
|
Optional[int]
|
Number of graphs in the batch, i.e. number of rows of the
output. By default, inferred as |
None
|
Returns:
| Type | Description |
|---|---|
array
|
An array with averaged node features for all provided graphs. |
Source code in mlx_graphs/nn/pooling/global_pooling.py
from mlx_graphs.nn import global_mean_pool · mlx_graphs/nn/pooling/global_pooling.py