↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

Message passing

A graph neural network computes a vector for every node of a graph from the node's own features and its neighbours'. Almost all of them share one pattern, message passing: in each layer every node sends a message along its edges, every node adds up what arrives, and a small learned function turns the sum into the node's new vector. Gilmer et al. (2017) gave the pattern its name and showed that many earlier models were instances of it:

This page uses the simplest instance, the graph convolution of Kipf and Welling (the GCN tab takes it apart): the message is the neighbour's vector times a shared weight matrix, scaled by a number that depends only on the two nodes' degrees, and the update is a ReLU. The graph is Cora, 2,708 machine-learning papers joined by 5,278 citations, each paper described by which of 1,433 words it uses and labelled with one of 7 topics. As in the Planetoid split of Yang et al. (2016), only 140 papers, 20 per topic, have labels the model may train on.

The receptive field

Because a layer only mixes a node with its direct neighbours, a node's vector after layers can depend only on the nodes at most edges away: its receptive field grows by one hop per layer. The Receptive field panel draws paper 2472 with every paper within 3 citations, in rings by distance: 7 papers lie within 1 citation (itself included), 19 within 2 and 64 within 3. The toolbar's layer buttons colour the papers that can reach 2472 after that many layers; everything outside is exactly irrelevant, not merely small.

How much each reachable paper matters is measured as Xu et al. (2018) do, by the influence of node on node : the sum of the absolute values of the Jacobian , scaled so the influences over all add up to 1. The circle sizes show it for the trained 3-layer GCN. Xu et al. proved that in expectation this influence equals the probability that a random walk of steps from ends at ; with GCN's normalization the corresponding weights are the entries of . The What reaches it panel compares the two by distance, and after 3 layers they agree closely: the trained model draws 14.5 % of its influence from the paper itself, 55.9 % from 1 citation away, 20.3 % from 2 and 9.3 % from 3, where gives 14.5, 55.6, 20.3 and 9.6 %.

The whole graph grows fast. The chart under the panel counts the papers within citations: the median paper reaches 4 papers in one layer, 18 in two, 78 in three, 281 in four and 821 in five, and from 13 layers on it reaches all 2,485 papers of the large connected component (the other 223 sit in small separate pieces).

Over-smoothing

A bigger receptive field sounds like more information, but every layer also averages. Repeated averaging over neighbours is a diffusion: applied often enough it makes the vectors of connected nodes alike, and then the network cannot tell the nodes apart. Li et al. (2018) identified this over-smoothing in GCNs as Laplacian smoothing, and Oono and Suzuki (2020) proved that the vectors of a deep GCN approach a subspace that carries only degree information, at an exponential rate set by the graph's spectrum and the weights' size.

The page measures it two ways. The Dirichlet energy, in the form of Rusch et al. (2023),

is 0 exactly when every connected pair has the same vector. The mean cosine similarity over all pairs of papers shows whether the vectors also point the same way, whatever their length. Both are computed for the output of every layer.

Even before training the effect is plain. In the Layer by layer charts' purple curves, at initialization, the energy falls from 0.48 at the input to about after 32 layers, and the papers' mean cosine climbs to 0.98–1.00 over the three seeds. The grey curve repeats this with no weights at all, : the propagation alone smooths, though it keeps the scale of each node's vector set by its degree, so its cosine settles near 0.72.

Depth against accuracy

The Over-smoothing column trains plain GCNs (64 wide, no residual connections, no normalization layers) 1, 2, 3, 4, 6, 8, 12, 16, 24 and 32 layers deep, three seeds each, with the same optimizer and 200 epochs. The test accuracy at the epoch with the best validation accuracy averages 77.3 % for one layer, 82.7 % for two, 81.9 % for three, 77.6 % for four and 70.2 % for six. From eight layers on no seed fits even its 140 training papers, and test accuracy falls to 20–28 %, below the 31.9 % a model would get by always answering the most common test topic.

Smoothing is not the only thing that goes wrong in the deep models: gradients through many layers are tiny, and the trained 32-layer models show what weight decay does to layers that receive almost no gradient. In all three seeds the first hidden layers shrink until the mean squared length of a paper's vector is a few times , and from the second layer on every paper's vector points the same way (mean cosine 1.000), so the last few layers have nothing left to tell the papers apart. The strip's matrix shows the effect on the papers around 2472: at two layers their vectors still differ; deep enough, every pair has cosine close to 1.

This is why practical GNNs stay shallow (two or three layers on citation graphs) or add residual connections, normalization or jumping-knowledge connections that let the output read every layer (Xu et al., 2018). The GCN and GAT tabs use the classic two layers.

How it was recorded

Every model on this page was trained here on a CPU, one thread, with denormal floats flushed to zero so reruns are bit-identical: Adam with learning rate 0.01 and weight decay , dropout 0.5, the whole graph in each of 200 steps, the paper word vectors scaled to sum to 1. The layers are written in plain PyTorch (the </> chips) and checked against PyTorch Geometric's GCNConv, MessagePassing and k_hop_subgraph; the check also recomputes the recorded influence and per-layer measures from the recorded weights and retrains the 2-layer model epoch for epoch.

Papers

  1. Neural Message Passing for Quantum Chemistry Justin Gilmer et al. · ICML 2017 The message-passing framework: messages along edges, a sum at each node, an update, repeated layer by layer.
  2. Semi-Supervised Classification with Graph Convolutional Networks Thomas N. Kipf, Max Welling · ICLR 2017 The GCN layer every model on this page stacks, and its Cora setup.
  3. Representation Learning on Graphs with Jumping Knowledge Networks Keyulu Xu et al. · ICML 2018 Influence as summed Jacobians, its link to random walks, and jumping-knowledge connections against over-smoothing.
  4. Deeper Insights into Graph Convolutional Networks for Semi-Supervised Learning Qimai Li, Zhichao Han, Xiao-Ming Wu · AAAI 2018 GCN as Laplacian smoothing, and the over-smoothing that many layers cause.
  5. Graph Neural Networks Exponentially Lose Expressive Power for Node Classification Kenta Oono, Taiji Suzuki · ICLR 2020 Proof that deep GCN features approach a degree-only subspace exponentially fast.
  6. A Survey on Oversmoothing in Graph Neural Networks T. Konstantin Rusch, Michael M. Bronstein, Siddhartha Mishra · arXiv 2023 The Dirichlet energy this page measures, and a comparison of the fixes.
  7. Revisiting Semi-Supervised Learning with Graph Embeddings Zhilin Yang, William W. Cohen, Ruslan Salakhutdinov · ICML 2016 Planetoid, whose split of Cora (140 / 500 / 1,000 papers) this page trains and tests on.

See also