Search

Search papers and lessons

Semi-Supervised Classification with Graph Convolutional Networks

Thomas N. Kipf, Max Welling · 2016

Kipf and Welling show that a two-layer graph network with a simple normalized propagation rule classifies unlabelled nodes more accurately and faster than the methods it is compared with.

On this page

  • Colour = topic mix
  • Linear algebra
  • Discrete math
  • Calculus
  • Probability
  • Architectures
  • Learning basics
  • Sign in to see your progress

TL;DR

Most labels in real data are missing. In a citation network, only a few papers have a known topic, but every paper cites others, and citations are a hint about topic. Kipf and Welling build a neural network that reads both the node features and the graph's edges in every layer. Its layer rule averages each node with its neighbours, normalized by degree, then applies a learned linear map and a ReLU. On four benchmark graphs a two-layer version beats the graph methods it is compared with, and it trains in under a minute.

Where you'll see it: node classification on citation, social and knowledge graphs, and as the template for most later graph neural networks.

The problem

Before this paper, the standard approach to semi-supervised learning on graphs had two steps. First, a graph-based regularizer forced connected nodes to share labels. This assumed that every edge means "same class," which is often false. A citation can mean "disagrees with," and a knowledge-graph edge can mean almost anything. Second, methods such as DeepWalk learned node embeddings from random walks and then trained a classifier on top. Each step was optimized separately, and the pipeline was slow to train on large graphs.

Neural networks on graphs existed, but they were either recurrent models that had to run to a fixed point, or they used a separate weight matrix for each node degree, which does not scale when degrees vary widely. The paper asks for a model that uses the edges as input rather than as a penalty, is trained end to end with the classification loss, and scales linearly in the number of edges.

Key idea

Keep the edges in the network. Let each layer mix every node's features with the features of its neighbours, so a node's representation after KK layers depends on its KK-hop neighbourhood. Train the whole thing with the ordinary cross-entropy loss on the few labelled nodes. The unlabelled nodes receive gradient information indirectly, because their representations flow into the representations of labelled nodes.

The picture: a node's features are blurred over its neighbourhood, then sharpened by a learned linear map. Nodes that sit in the same region of the graph end up with similar features, so a few labels spread through the graph the way a few drops of dye spread through water.

The paper's main technical contribution is the exact form of the blur. Averaging the raw neighbour features is unstable when stacked. The paper proposes a symmetric normalization, which the rest of this lesson derives.

The method

From spectral filters to a layer

Spectral graph convolutions define a filter in the Fourier basis of the graph Laplacian. Let L=IN−D−12AD−12=UΛU⊤L = I_N - D^{-\frac{1}{2}} A D^{-\frac{1}{2}} = U \Lambda U^\top be the normalized graph Laplacian, with eigenvectors UU and eigenvalues Λ\Lambda (see eigenvalues and eigenvectors). A filter gθg_\theta acts on a signal xx as gθ⋆x=Ugθ(Λ)U⊤xg_\theta \star x = U g_\theta(\Lambda) U^\top x. Computing this directly needs the full eigendecomposition, which costs O(N2)\mathcal{O}(N^2) to apply and more to compute for a large graph.

Section 2 of the paper avoids this in three steps. First, approximate gθ(Λ)g_\theta(\Lambda) with a Chebyshev polynomial of degree KK in the rescaled Laplacian. This makes the filter KK-localized: the output at a node depends only on nodes at most KK steps away, and it costs O(∣E∣)\mathcal{O}(|\mathcal{E}|). Second, set K=1K = 1 so that each layer is linear in LL, and assume the largest eigenvalue is about 2. Third, tie the two free coefficients to one parameter θ\theta. This leaves

gθ⋆x≈θ(IN+D−12AD−12)x.g_\theta \star x \approx \theta \left( I_N + D^{-\frac{1}{2}} A D^{-\frac{1}{2}} \right) x .

The operator IN+D−12AD−12I_N + D^{-\frac{1}{2}} A D^{-\frac{1}{2}} has eigenvalues in [0,2][0, 2]. Stacked many times, eigenvalues above 1 blow up and those below 1 shrink, which causes exploding or vanishing gradients in a deep network. The fix is the renormalization trick: add self-loops, A~=A+IN\tilde{A} = A + I_N, and use the degree matrix D~ii=∑jA~ij\tilde{D}_{ii} = \sum_j \tilde{A}_{ij}. For a signal with CC input channels and FF output channels the layer becomes

Z=D~−12A~D~−12XΘ,Θ∈RC×F.Z = \tilde{D}^{-\frac{1}{2}} \tilde{A} \tilde{D}^{-\frac{1}{2}} X \Theta, \qquad \Theta \in \mathbb{R}^{C \times F}.

The paper writes the multi-layer rule as H(l+1)=σ ⁣(A^H(l)W(l))H^{(l+1)} = \sigma\!\left(\hat{A} H^{(l)} W^{(l)}\right), where A^=D~−12A~D~−12\hat{A} = \tilde{D}^{-\frac{1}{2}} \tilde{A} \tilde{D}^{-\frac{1}{2}} is computed once before training and σ\sigma is an activation function such as ReLU.

The two-layer classifier

The model used in the experiments has two layers and a softmax output:

Z=f(X,A)=softmax ⁣(A^ ReLU ⁣(A^XW(0))W(1)).Z = f(X, A) = \mathrm{softmax}\!\left( \hat{A}\, \mathrm{ReLU}\!\left( \hat{A} X W^{(0)} \right) W^{(1)} \right).

Here XX is the feature matrix, one row per node, W(0)∈RC×HW^{(0)} \in \mathbb{R}^{C \times H} maps input features to HH hidden units, and W(1)∈RH×FW^{(1)} \in \mathbb{R}^{H \times F} maps hidden units to FF classes. The Softmax is applied row by row, so each row of ZZ is a probability distribution over classes for one node.

Training uses the cross-entropy summed over the labelled nodes only:

L=−∑l∈YL∑f=1FYlfln⁡Zlf,\mathcal{L} = - \sum_{l \in \mathcal{Y}_L} \sum_{f=1}^{F} Y_{lf} \ln Z_{lf},

where YL\mathcal{Y}_L is the set of labelled node indices and YlfY_{lf} is 1 when node ll has class ff. Unlabelled nodes do not appear in the loss, but they appear in ZZ through the propagation, so their features still shape the trained weights. The weights are fit by gradient descent, with dropout used in the layers for regularization.

Cost

The sparse matrix A^\hat{A} needs memory linear in the number of edges. The paper states the cost of one forward pass of the two-layer model as O(∣E∣CHF)\mathcal{O}(|\mathcal{E}| C H F), linear in the number of edges. It trains on the full graph in every iteration, which is practical as long as the graph fits in memory.

Relation to the Weisfeiler-Lehman test

Appendix A shows that the same rule, with a learned map in place of the hash function, is a differentiable version of the one-dimensional Weisfeiler-Lehman colour-refinement algorithm. This is why even an untrained GCN with random weights gives useful node embeddings on Zachary's karate club network; the paper reports them as comparable to DeepWalk's. The appendix uses it as an intuition, not as a proof of expressive power.

Results

All numbers below are from the paper's tables, with its reported units.

Datasets (Table 1, as reported in Yang et al.). Citeseer has 3,327 nodes, 4,732 edges and 6 classes. Cora has 2,708 nodes, 5,429 edges and 7 classes. Pubmed has 19,717 nodes, 44,338 edges and 3 classes. NELL is a bipartite graph from a knowledge base with 65,755 nodes, 266,144 edges and 210 classes. The citation networks use 20 labels per class for training, a validation set of 500 labelled nodes and a test set of 1,000.

Accuracy (Table 2, percent). The GCN row is the paper's model, with its wall-clock training time in seconds in brackets.

MethodCiteseerCoraPubmedNELL
LP45.368.063.026.5
DeepWalk43.267.265.358.1
ICA69.175.173.923.1
Planetoid (best variant)64.7 (26 s)75.7 (13 s)77.2 (25 s)61.9 (185 s)
GCN (this paper)70.3 (7 s)81.5 (4 s)79.0 (38 s)66.0 (48 s)
GCN, 10 random splits67.9 ± 0.580.1 ± 0.578.9 ± 0.758.4 ± 1.7

The GCN has the highest accuracy on all four datasets in the fixed-split setting. The random-split row is lower than the fixed-split row on every dataset, and its standard errors show how much the result depends on which nodes are labelled. Only the GCN is reported on random splits, so the baselines cannot be compared on that row.

Propagation rules (Table 3, percent, citation datasets). The paper compares its renormalized rule against alternatives, each substituted into both layers.

Propagation modelCiteseerCoraPubmed
Chebyshev, K=2K = 269.681.273.8
Chebyshev, K=3K = 369.879.574.4
First-order model68.380.077.5
Single parameter69.379.277.4
Renormalization trick (GCN)70.381.579.0
First-order term only68.780.577.8
No propagation (MLP)46.555.171.4

The last row is the most informative: removing propagation costs about 24 points on Citeseer and 26 points on Cora. The renormalized rule is best on all three datasets. The paper argues for it on two grounds: its propagation is more stable across layers, and it has fewer parameters and operations than the alternatives.

Training setup. Adam with learning rate 0.01, at most 200 epochs, and early stopping after 10 consecutive epochs without a drop in validation loss. Hyperparameters (dropout rate, L2 factor on the first layer, number of hidden units) are tuned on Cora only, using the 500-node validation set, and reused for Citeseer and Pubmed. The depth experiments in Appendix B list dropout 0.5, L2 5⋅10−45 \cdot 10^{-4} and 16 hidden units. The GCN rows report the mean of 100 runs with random weight initializations.

Scaling. Figure 2 reports the time per training epoch on random graphs with NN nodes and 2N2N random edges, on a GPU and on a CPU, and marks runs that ran out of memory. The complexity analysis predicts cost linear in the number of edges; read the measured timings off the figure.

Depth. The appendix finds the best accuracy with two or three layers. Beyond about seven layers, training without residual connections becomes difficult, because each node's receptive field grows with every layer and the model overfits.

Why it mattered

The paper turned graph neural networks from a niche tool into a default one. Its rule is a few lines of code: a sparse matrix product, a dense weight matrix and a nonlinearity. That simplicity made it easy to reproduce, to extend and to compare against.

Many later models keep the same skeleton and change one part: attention weights in place of fixed normalization, sampling of neighbours for very large graphs, residual connections for depth, or different aggregation functions. The paper itself names the main limits that later work tried to fix: memory that grows with the full graph, no native support for edge features or directed edges, and a fixed assumption that edges mean similarity. Section 7 of the paper lists these explicitly.

Reading guide

Read the paper in this order. The prerequisites in brackets are the ones the section needs.

  1. Section 1 (introduction). graph Laplacian and Semi-Supervised Learning set up the problem. The regularization term in Equation 1 is the baseline the paper argues against.
  2. Section 2 (fast approximate convolutions). Needs eigenvalues and eigenvectors and the adjacency matrix. Section 2.1 is the spectral derivation; the Chebyshev step can be skimmed if you accept that the result is a KK-localized filter. Section 2.2 is where the renormalization trick is introduced, so read it closely.
  3. Section 3 (semi-supervised node classification). the GCN layer is the object of this section. Needs Softmax, Cross-Entropy Loss, ReLU and Dropout. Section 3.1 has the full model and is the most important part of the paper.
  4. Section 4 (related work). Needs nothing new. Read it to see which families of methods the paper contrasts with: Laplacian regularization, skip-gram embeddings, and earlier graph neural networks.
  5. Section 5 (experiments). Needs Gradient Descent for the training setup, and convolutional neural networks for the analogy the paper draws. The dataset descriptions only need the definitions of nodes, edges and labels.
  6. Section 6 (results). Read Tables 2 and 3 with the description in Section 5.2 next to them, so you know which splits and hyperparameters produced each number.
  7. Section 7 (discussion and limitations). Needs no new prerequisites. It is the best guide to what the method does not do.
  8. Appendices A and B. Appendix A needs the Weisfeiler-Lehman colour-refinement idea, which the paper presents as its Algorithm 1. Appendix B needs only the residual connection idea.

Check yourself

QuestionIn one or two sentences, what does the GCN layer compute for each node, and why does it help a node with few labels?Show answer

For each node, the layer takes the average of its own features and its neighbours' features, weighted by degree-normalized edge weights, applies a learned linear map and a ReLU. A node with few labels gets a representation that already reflects its neighbourhood, so a label on a nearby node influences its prediction through the shared weights, even though the node itself has no label.

QuestionThe paper's Table 3 shows the no-propagation MLP gets 46.5 percent on Citeseer and the GCN gets 70.3 percent. What is the gap, and what does it measure?Show answer

The gap is 70.3 minus 46.5, which is 23.8 percentage points. It measures how much the graph structure adds, holding the feature inputs, the number of weights and the training procedure roughly fixed. It is an ablation of propagation, not of depth.

QuestionWhy does the renormalization trick add self-loops and divide by the degree, instead of just using the raw adjacency matrix AA?Show answer

Without self-loops, a node's own features are dropped in the update, so the representation forgets the node itself. Without normalization, the eigenvalues of the propagation operator lie in [0,2][0, 2] for the first-order model, and repeated multiplication across layers makes activations and gradients explode or vanish. Adding INI_N and using the symmetric degree normalization keeps the spectrum bounded, which makes deep stacks trainable.

QuestionYou have a graph of 50,000 nodes with an average degree of 10, and you want to train a two-layer GCN with 64 hidden units on it in full-batch mode. Roughly how many multiply-adds does one forward pass need, and what is the bigger concern?Show answer

Count the edges as about 50,000×10/2=250,00050{,}000 \times 10 / 2 = 250{,}000 undirected edges. Each edge gives two nonzero entries in A^\hat{A}, and the self-loops add 50,000 more, so A^\hat{A} has about 550,000550{,}000 nonzeros. The sparse product with 64 hidden units costs about 550,000×64≈3.5×107550{,}000 \times 64 \approx 3.5 \times 10^7 multiply-adds for the first layer, plus the cost of the feature product XW(0)X W^{(0)}, which is not counted here. The bigger concern is memory: full-batch training keeps all node activations for every layer in memory at once, and the paper names this as the main limitation for very large graphs.

Sources

Read the full paper

Thomas N. Kipf, Max Welling, 2016. arXiv:1609.02907