Graph Convolutional Networks
A graph convolutional network (GCN) is a GNN whose layers combine neighbors through a fixed matrix built from the graph. The node vectors are the rows of , and is the adjacency matrix. The graph is undirected, so is symmetric. The degree matrix holds the neighbor counts on its diagonal. One layer computes
The weights and the bias are shared by all nodes. The vector holds ones, and acts elementwise. The propagation matrix decides how each node mixes with its neighbors. Adding self-loops gives , with degrees on the diagonal of . The common choices are:
- Sum with self: adds the neighbors to the node.
- Diagonal enhancement: gives the node the weight , with a learned scalar per layer.
- Mean plus self: averages the neighbors and then adds the node.
- Mean with self-loops: averages the node together with its neighbors.
- Symmetric (Kipf-Welling): gives the message from to the weight .
Other layers change how the node and its neighbors combine:
- Separate self weight: gives the node its own matrix .
- Residual: the layer adds or concatenates the old to the activated neighbor term.
- Max aggregation: the elementwise maximum over neighbors replaces the weighted sum.
- Graph attention: weights computed from the node vectors replace . A softmax over each node and its neighbors normalizes them, and non-neighbors get weight .
Every such layer is permutation equivariant. A layer of the main form has parameters, whatever the size of the graph. In the inductive setting, a GCN learns from labeled graphs and then labels new graphs. In the transductive setting, one graph has some labeled nodes, and the GCN labels the remaining nodes of that graph. Graph-level tasks are always inductive.
Not Taught in Lecture
Lecture derived the general message-passing update and listed sum, mean and max aggregators. The matrix form and the named propagation matrices follow Prince §13.4 and §13.8. Diagonal enhancement is from Chiang et al. (2019). The symmetric normalization with self-loops is from Kipf and Welling (2017). Averaging the node together with its neighbors is the mean aggregator of GraphSAGE (Hamilton et al., 2017). Inductive and transductive learning follow Prince §13.6.
Rows Versus Columns
Prince stores node vectors as the columns of a matrix and writes . This note stores them as the rows of and writes with . Prince’s mean aggregation becomes in row form. Prince’s Kipf normalization adds the node after normalizing. The original paper puts the self-loop inside the normalization.
Intuition
Message passing leaves the message function and the update function open. A GCN makes both linear and lets them share one matrix . Each node then sends the row , and each receiver adds the rows it gets. For all nodes at once, the layer is one sparse matrix product followed by an activation. The design question is how to weight the incoming rows. A plain sum keeps information about the number of neighbors. With similar features everywhere, a hub with a thousand neighbors gets activations about a thousand times larger than a leaf. Normalized matrices keep every node on the same scale. The symmetric version also shrinks the messages that a hub sends, since many receivers share them. Self-loops keep each node’s own features in its update. The figure shows the symmetric weights on a star with one hub and three leaves.
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\begin{tikzpicture}[x=1.6cm,y=1.6cm,nd/.style={circle,draw,very thick,minimum size=9mm,inner sep=0pt}]
\node[nd,hot] (h) at (0,0) {hub};
\node[nd,cold] (a) at (90:1.6) {$1$};
\node[nd,cold] (b) at (210:1.6) {$2$};
\node[nd,cold] (c) at (330:1.6) {$3$};
\foreach \x/\s in {a/left,b/right,c/left} \draw[thick] (h) -- (\x) node[midway,inner sep=3pt,auto=\s] {\small $0.354$};
\draw[thick,hot] (h.300) to[out=300,in=240,looseness=6] (h.240);
\node[hot] at (0,-1.0) {\small $1/4$};
\foreach \x/\ang in {a/90,b/210,c/330} {
\draw[thick,cold] (\x.\ang+30) to[out=\ang+30,in=\ang-30,looseness=6] (\x.\ang-30);
\node[cold] at (\ang:2.62) {\small $1/2$};
}
\node[anchor=west] at (1.75,0.9) {$\tilde d = 4$ at the hub};
\node[anchor=west] at (1.75,0.55) {$\tilde d = 2$ at each leaf};
\end{tikzpicture}
\end{document}Derivation
We want to show that linear message passing gives the GCN layer and that this layer is permutation equivariant. Start from the update . Choose the message and the update . Transposing to rows, node computes
The term in the inner parentheses is row of . Stacking the rows gives . Dividing the neighbor sum by gives row of , the mean-plus-self layer. Dividing the whole term by gives the mean with self-loops. Weighting each term by gives the symmetric layer.
For equivariance, relabel the nodes with a permutation matrix . The adjacency matrix becomes , and the degree matrices become and . Each propagation matrix above is built from these, so it becomes . Using and ,
The activation acts on each entry and commutes with reordering rows. The output for the relabeled graph is therefore , the old output with its rows reordered.
Properties
(Self-Loops Keep the Node) Without self-loops, a node ignores its own features, and a bipartite graph makes the signal jump between sides.
The adjacency matrix has zeros on its diagonal, so row of contains only neighbor vectors. A bipartite graph splits its nodes into two sides with edges only between sides, as in every tree. One multiplication by moves all content to the other side, and the next moves it back. Deep sum layers without self-loops therefore alternate between two patterns. The identity in fixes both problems. A separate self matrix fixes them too and lets the node weight itself differently from its neighbors.
(Scale and Spectrum) The sum layer scales activations with node degree, while the mean with self-loops and the symmetric matrix have every eigenvalue in .
Applied to a constant signal, returns the degrees . Stacking sum layers multiplies a smooth signal by roughly the largest eigenvalue of at every layer. The rows of sum to , so its largest eigenvalue is with eigenvector . The symmetric matrix equals . It therefore has the same eigenvalues, and its top eigenvector is . The self-loops keep every eigenvalue above . Repeated multiplication then cannot make any part of the signal grow. The mean-plus-self matrix adds after normalizing, so its eigenvalues lie in . The next property explains why this matters.
(Renormalization Trick) Normalizing without self-loops and adding afterwards allows eigenvalues up to .
Not Taught in Lecture
This argument is from Kipf and Welling (2017), Section 2.2.
The matrix has its eigenvalues in . Adding shifts them to . A stack of such layers can amplify a signal by up to before the weights act. Gradients can then explode or vanish. Kipf and Welling move the self-loop inside the normalization and use instead. They call this replacement the renormalization trick.
(Symmetric Versus Mean) The mean weights a message by the receiver’s degree, and the symmetric matrix also uses the sender’s degree.
Under , node gives each incoming message the weight , so its output is a weighted average. Under the symmetric matrix the weight is . A hub with many links sends small messages, on the view that each of its links carries less specific information. The symmetric output is not an average, and a constant signal does not stay constant. In exchange, is a symmetric matrix. It therefore has real eigenvalues and orthogonal eigenvectors, and the spectral derivation of the original paper relies on both.
(Oversmoothing in Linear GCNs) Repeating a normalized propagation matrix drives every row toward one shared vector.
For a connected graph, approaches as grows. The weights are the long-run visit frequencies of a random walk on the graph. Every node ends with the same degree-weighted average of the input. The symmetric matrix gives rows proportional to times one shared vector, so the nodes again carry the same information. Differences shrink at each layer by the second-largest eigenvalue magnitude. Prince cites oversmoothing as one possible reason that the original GCN used only two layers. Nonlinearities between layers and residual connections slow the decay.
(One-Hot Inputs Make a Model Transductive) With one-hot node features, the first weight matrix stores one learned row per node.
When there are no node features, a common choice is . The first layer then computes , and row of is a learned embedding of node . A new node has no row, and a new graph has different nodes. Such a model must be retrained when the graph changes. Descriptive features, such as a person’s age or a paper’s words, let the same weights work on new nodes. In transductive training, every node takes part in the forward pass, and the loss uses only the labeled nodes.
(Graph Attention) Graph attention computes each neighbor’s weight from the two node vectors involved.
Not Taught in Lecture
This layer follows Prince §13.8.6 and Veličković et al. (2018). Lecture’s attention block scored pairs with a bilinear form instead.
Each node first computes . A learned vector scores each pair as , where is an activation. Scores for non-neighbors are set to . A softmax over then turns the scores into weights that sum to . The output is . Two neighbors with the same degree can now receive different weights. The layer resembles transformer self-attention masked to each node’s neighborhood. It uses the same transformed vectors as keys, queries and values, and it scores pairs differently. Several heads can run in parallel and be combined, as in a transformer.
(Batching Graphs) A batch of graphs is one large graph made of disjoint pieces.
Not Taught in Lecture
This trick is from Prince §13.5.1.
Graphs in a batch have different sizes, so their matrices cannot be stacked into one tensor. The network instead places the adjacency matrices on the diagonal of one block-diagonal matrix and stacks the feature rows. No edges join different graphs, so no messages cross between them. The GCN layers run once on the combined graph. A readout then pools the rows of each graph separately, giving one vector per graph for the loss.
(Edge Graphs) Edge features can be processed by running the same layers on the edge graph.
Not Taught in Lecture
Edge graphs are from Prince §13.9.
The edge graph, or line graph, has one node for each edge of the original graph. Two of its nodes are linked when the original edges share an endpoint. Message passing on the edge graph updates edge vectors from neighboring edges. A network can alternate updates between the two graphs, so nodes update edges and edges update nodes.
Examples
(Easy) A Hub Without Self-Loops
An airline network has one hub airport linked to three regional airports. The feature of each airport is its number of delayed flights, with the hub first.
Apply once, twice and three times. Then apply once. One sum layer gives . The hub loses its own delays, and each regional airport receives the hub's. A second layer gives , and a third gives . The star is bipartite, so the signal jumps between the hub and the regional airports. With self-loops, , and the hub keeps its own count.
(Medium) Three Normalizations on One Star
Use the same star with self-loops, so .
Apply the sum , the mean with self-loops and the symmetric matrix to the constant signal and to . Which vector does each normalized matrix leave unchanged? On its diagonal, the symmetric matrix has for the hub and for each regional airport. Each entry between the hub and a regional airport is . For the constant signal, the sum gives and the mean gives . The symmetric matrix gives . For the hub signal, the sum gives , the mean gives and the symmetric matrix gives .
The mean leaves unchanged, since its rows sum to . The symmetric matrix leaves unchanged. Both matrices have eigenvalues . The matrix has eigenvalues , so ten such layers could amplify a signal by .
(Hard) Watching Oversmoothing Happen
Four sensors along a pipeline form the path . Sensor 1 reads and the others read . A linear GCN applies repeatedly, with no weights or activations.
Compute the first three layers, the limit, and the speed of convergence. . Each node averages itself with its neighbors: The gap between the largest and smallest reading falls from to , and . The limit gives every node , since . The second-largest eigenvalue magnitude is . After layers the gap is , and after layers it is . With the symmetric matrix, the limit is , which is . After layers each reading is within of its limit.
The degrees with self-loops are
See Also
- 6.1.1. Message Passing, the general update that a GCN specializes.
- 6.1.3. Graph Pooling, for graph-level readouts and for shrinking graphs between layers.
- 7.1. Attention, the attention mechanism that graph attention adapts.
- 7.1.1. Multi-Head Attention, for several attention heads in parallel.
- 4.5.2. Layer Normalization, a normalization that works on graphs of any size.