liveBook · Manning

Global_mean_pool

As explained in Build AI Drug Discovery Pipelines

global_mean_pool is a graph pooling operation that averages node features separately for each graph in a batch.

global_mean_pool converts a batch of variable-sized graphs into one feature vector per graph by averaging node features separately within each batch index. section 11.5.5

For three disjoint graphs containing 37 total nodes:

  • The batch vector labels nodes with graph indices: 0, 1, or 2. section 11.5.5
  • The operation averages nodes 0–9, 10–24, and 25–36 separately. section 11.5.5
  • The result contains three output vectors, one representing each graph. section 11.5.5
from torch_geometric.data import Batch
def collate(data_list):
    batchA = Batch.from_data_list([data[-1] for data in data_list])
    batchB = Batch.from_data_list([data[0] for data in data_list])
    return batchA, batchB

Builds batched graph objects with Batch.from_data_list before applying graph-level pooling. section 11.5.5

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Explains batch-index grouping, averaging, output shape, and efficient variable-size processing, without detailing reduction internals.
Examples
Uses 37 nodes distributed across three graphs and averages node ranges 0–9, 10–24, and 25–36.
What it assumes
Assumes node features, graph batches, batch indices, and preceding graph-convolution processing.
What you can do after
Apply it via PyTorch Geometric to obtain one graph representation from each batched variable-size graph.
How it connects
Connects graph pooling with message passing, batch vectors, GCN layers, and variable-size graph batching.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.