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, batchBBuilds batched graph objects with Batch.from_data_list before applying graph-level pooling. section 11.5.5
