Graph Pooling
Graph pooling turns many nodes into few. A CNN pools to grow its receptive fields faster and to reach one output per image. On a grid, pooling merges fixed windows. A general graph has no windows, so going from many nodes to few is a clustering problem. The main approaches are:
- Readout (global pooling): the network sums, averages or takes the elementwise max of the node vectors at the last layer. The result is , or . This vector has a fixed size for any and ignores node order. A graph-level head maps to the output.
- Global node: an extra node is linked to every node. Its final vector summarizes the graph, and any two nodes are at most hops apart through it.
- DiffPool: a learned soft clustering shrinks the graph from nodes to clusters inside the network.
DiffPool runs a separate small GNN on the current graph. This GNN outputs scores per node, and a softmax over each node’s scores gives its memberships. Row of the assignment matrix is , the probabilities that node belongs to each cluster. The pooled node vectors and the pooled adjacency matrix are
Row of the first product is . Each cluster vector is a sum of node vectors, weighted by their memberships in that cluster. Entry is the strength of the edge between clusters and . The pooled graph is dense and has real-valued edge weights. Later layers multiply each message by its weight and do not normalize it right away. The whole network trains end to end, helped by two auxiliary losses:
- Link loss : entry of is the inner product . The loss pushes linked nodes into the same cluster.
- Entropy loss , with : it is smallest for one-hot rows and pushes the memberships toward hard assignments.
Not Taught in Lecture
DiffPool is by Ying et al., published at NeurIPS 2018. Lecture gives the year as 2019. The paper computes with a pooling GNN and pools the output of a separate embedding GNN, . Lecture pooled directly. Prince §13.3.1 uses the mean readout. The sum and max readouts follow Xu et al. (2019), cited in Prince’s chapter notes. Other pooling layers, such as SortPool and self-attention pooling, appear only in Prince’s chapter notes.
Intuition
A CNN halves the resolution at each pooling layer, so a few layers cover the whole image. A GNN without pooling keeps all nodes in every layer. Its receptive field grows by one hop per layer, and distant information must pass through many intermediate nodes. Shrinking the graph would help, but a graph has no fixed windows to merge. Merging nodes is a clustering problem, and good clusters depend on both the node vectors and the edges. Hard clustering, such as k-means with Lloyd’s algorithm, puts each node in exactly one cluster. Its assignments are discrete, so their gradient is zero almost everywhere. Hard clustering therefore cannot be a layer of the network. DiffPool lets every node belong to every cluster with some probability. A small GNN produces the probabilities, so the network learns how to cluster from the task loss. An undirected graph without edge labels can also skip pooling and end with a readout. DiffPool turns it into a graph with scalar edge weights, the infinite-label case of message passing. The figure pools a five-node graph into two clusters.
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\begin{tikzpicture}[x=1.2cm,y=1.2cm,nd/.style={circle,draw,very thick,minimum size=7mm,inner sep=0pt}]
\draw[hot,thick,dashed] (0.42,0) ellipse (1.5 and 1.45);
\draw[cold,thick,dashed] (3.27,0) ellipse (1.12 and 1.05);
\node[nd,hot] (a) at (0,0.75) {$1$};
\node[nd,hot] (b) at (0,-0.75) {$2$};
\node[nd,hot] (c) at (1.3,0) {$3$};
\node[nd,cold] (d) at (2.6,0) {$4$};
\node[nd,cold] (e) at (3.9,0) {$5$};
\draw[thick] (a) -- (b) (a) -- (c) (b) -- (c) (c) -- (d) (d) -- (e);
\node[left] at (a.west) {\small $0.9$};
\node[left] at (b.west) {\small $0.9$};
\node[above] at (c.north) {\small $0.7$};
\node[above] at (d.north) {\small $0.2$};
\node[above] at (e.north) {\small $0.1$};
\node at (1.9,-1.85) {\small number beside node $i$: membership $s_i[1]$};
\draw[-{Stealth[length=2.5mm]},very thick] (4.55,0) -- (5.65,0) node[midway,above] {pool};
\node[nd,hot,minimum size=9mm] (p) at (6.4,0) {$C_1$};
\node[nd,cold,minimum size=9mm] (q) at (8.4,0) {$C_2$};
\draw[thick] (p) -- (q) node[midway,above] {\small $2.38$};
\draw[thick,hot] (p.60) to[out=60,in=120,looseness=6] (p.120);
\node[hot] at (6.4,1.15) {\small $6.62$};
\draw[thick,cold] (q.60) to[out=60,in=120,looseness=6] (q.120);
\node[cold] at (8.4,1.15) {\small $3.62$};
\node at (7.4,-0.85) {\small $\mathbf S^T\tilde{\mathbf A}\,\mathbf S$};
\end{tikzpicture}
\end{document}Properties
(Why Hard Assignments Block Learning) A hard cluster label does not change under small changes of its inputs, so no gradient flows through it.
Lloyd’s algorithm assigns node to , where is the center of cluster . A small change in or in the centers leaves unchanged, except at a boundary where it jumps. The derivative of is therefore zero or undefined. The layers before pooling get zero gradient through the assignments. A softmax over scores has , which is positive whenever . Soft memberships therefore pass gradient back to the pooling GNN and to everything before it.
(Content and Edge Weight Are Conserved) Rows of that sum to keep the total of the node vectors and the total edge weight.
The rows of satisfy . Summing the pooled vectors gives , the sum of the original vectors. The same step gives for the edge weights. The column sums of are the soft cluster sizes. A cluster vector is a sum, so it grows with cluster size. Dividing it by the column sum turns it into a mean. With hard assignments, counts the edges between clusters and . A diagonal entry counts each edge inside the cluster twice, once in each direction, plus its self-loops.
(Pooled Graph Ignores Node Order) Relabeling the input nodes leaves the pooled graph unchanged.
The pooling GNN is permutation equivariant, so relabeling the nodes with turns into . Then . The adjacency matrix gives in the same way. The output columns of the pooling GNN fix the order of the clusters. A readout after the last DiffPool layer is therefore invariant to the input order.
(The Diagonal Matters in the Link Loss) Zeros on the diagonal of penalize hard clusters in the link loss.
The diagonal of holds , which equals for a one-hot row and is smaller otherwise. If has zeros on its diagonal, every one-hot row pays an error of there. The loss can then prefer blurred memberships to correct hard ones. Putting self-loops on the diagonal, , removes this penalty. The matrix has rank at most . By the Eckart-Young theorem, the link loss can never fall below the error of the best rank- approximation of . See 13.3 Low-Rank Approximation.
(Why the Entropy Loss Is Needed) Without the entropy loss, uniform memberships give every cluster the same scaled global sum.
If every row of equals , then every pooled vector equals . The pooled graph then holds identical nodes linked by identical weights. The network has learned a global readout with extra cost. Nearly uniform rows cause a milder version of the same blur. The entropy loss pushes each row toward one cluster, so the clusters stay distinct. Its weight and the weight of the link loss are hyperparameters.
(Readout Is DiffPool With One Cluster) With , DiffPool reduces to the sum readout.
A softmax over a single score always returns , so . The pooled vector is , the sum readout. The pooled adjacency is the scalar , the total edge weight. Larger keeps some structure that a readout discards. A deep network can alternate GNN layers and DiffPool layers. It shrinks nodes to , then to , and finally to one. A CNN alternates convolutions and pooling in the same way.
(Global Node and Oversquashing) A global node shortens every route to two hops, but all long-range information then passes through one vector.
Every pair of distant nodes now communicates through the same node of size . A graph with thousands of nodes must fit everything it shares into that one vector. The global node is the extreme case of the oversquashing described in 6.1.1. Message Passing. The global node also has neighbors, so a sum aggregator gives it activations that grow with the graph. A mean aggregator or a normalized update keeps its scale fixed.
Examples
(Easy) Readout Needs Message Passing First
A triangle molecule and a three-atom chain both have one scalar feature on every atom. A network ends with a sum readout.
Compare the readouts with no GNN layer, after one sum layer , and after one mean layer . With no layer, both readouts are , so the network cannot tell the molecules apart. The sum layer gives on the triangle and on the chain. The readouts become and , and the structure is now visible. The mean layer gives on both graphs, because every average of ones is one. Both readouts stay at .
(Easy) Hard Versus Soft Assignment
A pooling GNN gives node 3 of a graph the scores for two clusters.
Compute the hard and the soft assignment and the derivative of the cluster-1 membership with respect to . The hard assignment picks the larger score and gives . Raising or lowering slightly keeps it at , so the derivative is . The softmax gives and . Its derivative is . A small increase in moves node 3 further into cluster 1. The loss gradient with respect to can therefore be nonzero.
(Medium) Pooling a Five-Person Network
Five people form the graph from the figure, with edges , , , and . Each person has a feature vector of (hours of chess, hours of football) per week. The rows of are , , , and . The adjacency matrix has self-loops, . The pooling GNN outputs
Compute and , and check that both conserve their totals. Cluster 1 collects . Cluster 2 collects in the same way. Cluster 1 holds the chess players and cluster 2 the football players. The two pooled rows add up to , the column totals of . The soft cluster sizes are the column sums of , and . The pooled adjacency matrix is Its entries add up to , the total of . That total is for the five edges counted twice, plus for the self-loops. A hard assignment with node 3 in cluster 1 and node 4 in cluster 2 would give . The single bridge becomes a weight of . The soft memberships spread part of the within-cluster weight onto the bridge, which rises to .
(Hard) Scoring Assignments With the Auxiliary Losses
Compare three assignments for the same graph: the soft above, the hard assignment and , and the uniform assignment with every entry . Use natural logarithms.
Compute the link loss with and with , and the mean entropy, for each assignment. With , the link loss is for the soft assignment and for the hard one. The hard version misses only the bridge entries and , giving . The uniform has every entry . Every entry of is or , so the loss is . The Eckart-Young bound for rank is , so no assignment with two clusters can go below it.
The plain has zeros on the diagonal. With it, the losses become for soft, for hard and for uniform. The hard assignment now pays on each of the five diagonal entries and scores worse than the uniform one.
The soft has row entropy in rows 1, 2 and 5. Row 3 has , and row 4 has . Their mean is . The hard assignment has entropy , and the uniform one has . With self-loops, both auxiliary losses rank the hard assignment first and the uniform one last.
See Also
- 6.1.1. Message Passing, for the layers that run before and after pooling.
- 6.1.2. Graph Convolutional Networks, a common choice for the embedding and pooling GNNs.
- 5.2.2. Pooling, the grid version that DiffPool generalizes.
- 1. Shannon Entropy, the entropy used in the second auxiliary loss.
- 4.9a Frobenius Norm, the norm in the link loss.