liveBook · Manning

Data aggregation

As explained in Graph Neural Networks in Action

An aggregation function combines multiple neighborhood messages or feature values into a single representation.

Data aggregation combines features or messages from a node’s neighborhood into a representation the node can use. It is central to message passing: each GNN layer gathers local information, transforms it, and updates node embeddings. Aggregation matters when a prediction depends on relationships between nodes, such as categorizing products in a graph. section 3.2 section 3.4.2

For a one-hop neighborhood, start with the features of nodes connected to the central node. Combine them with an operation such as mean, sum, or max. Neighbor order must not change the result: a graph’s node ordering is not part of the information being modeled. The combined features then pass through the layer’s transformation and update steps. section 3.4.1 section 3.4.2

The choice of aggregation changes what a layer emphasizes:

  • Mean represents typical neighborhood features; sum retains their combined magnitude. Either can blur features that matter in a particular task. section 3.2 section 3.2.3
  • Max highlights strong individual features, but can overemphasize outliers when typical behavior matters. section 3.2.3
  • A GCN sums neighboring information with symmetric normalization to address differences in node degree. Self-loops also bring the central node’s features into its embedding. section 3.4.3
  • GraphSAGE aggregates a randomly sampled subset of neighbors rather than requiring the entire neighborhood. Its SAGEConv layer supports choices including mean, pool, and LSTM aggregation. section 3.4.6 section 3.1.2

In PyTorch Geometric, set GraphSAGE aggregation per SAGEConv layer, or pass a list such as ['max', 'sum', 'mean'] to use several strategies in one layer. A first-layer mean followed by second-layer max is another option. These configurations should be tested rather than assumed to improve performance; graph connectivity, feature distributions, runtime, and memory needs all affect the choice. Jumping Knowledge is related but different: it combines outputs from different layers. section 3.2.2 section 3.2.3

Table 3.5 Classification performance for GraphSAGE models with list aggregations added
Aggregation type
F1 score
Log loss
Mean (default)
0.7406
2.1214
Sum
0.7384
2.2496
Max
0.7449
2.1039
Layered: Mean →Max
0.7316
2.2041
Layered: Sum →Max
0.7344
2.345
List (standard)
0.7484
2.622
List (exotic)
0.745
2.156

Compare F1 score and log loss for single, per-layer, and list aggregations on the same GraphSAGE classification task. The highest F1 score does not correspond to the lowest log loss. section 3.2.2

How Graph Neural Networks in Action covers it

How deep it goes
Works from mean, sum, and max through GCN normalization, GraphSAGE sampling, and PyG configuration, without a rigorous derivation.
Examples
Compares mean, sum, max, per-layer, and list aggregations using GraphSAGE classification F1 scores and log losses.
What it assumes
Introduces one-hop neighborhoods and message-passing steps while using node features, embeddings, and neural-network layers.
What you can do after
Apply it via PyTorch Geometric SAGEConv, then evaluate aggregation choices against task metrics and scalability constraints.
How it connects
Links aggregation to message passing, graph convolutional networks, GraphSAGE, permutation invariance, and Jumping Knowledge networks.

Also explained in

Compare how 19 books explain data aggregation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.