Simple Algorithm
Deep Learning · Representation · 24 min

Graph Neural Networks

Message passing on graphs, from molecules to social networks.

A molecule, a social network and a road map share one awkward property: their parts come in no natural order. There is no first atom and no top-left friend, so neither a convolution nor an MLP on a flattened table fits them. This lesson builds the networks that do fit: message passing, the graph convolution derived from spectral filters, sampled and attention-weighted neighborhoods, and readouts that turn a whole graph into one vector.

What you’ll learn

  • Describe graph data by an adjacency matrix and node features, name the node-, edge- and graph-level tasks, and show why GNN layers must be permutation-equivariant and readouts permutation-invariant.
  • Write the message-passing framework (message, aggregation, update), implement a layer with one message per edge, and count its cost.
  • Derive the GCN propagation rule from first-order spectral filters, including the renormalization trick, and compare it with GraphSAGE's sampled aggregators and GAT's attention.
  • Build graph-level predictions with sum, mean or max readouts and hierarchical pooling, and connect them to Deep Sets.
  • Explain how depth sets a node's receptive field, why most GNNs stay shallow, and where GNNs have been applied with documented results.

Graphs, tasks and the symmetry to respect

A graph G=(V,E)G=(V,E) has n=∣V∣n=\abs V nodes joined by edges. Store the edges in the adjacency matrix A∈{0,1}n×nA\in\{0,1\}^{n\times n}, with Auv=1A_{uv}=1 when uu and vv are joined, and the node features in the rows of X∈Rn×dX\in\R^{n\times d}; edges can carry features euv\mathbf e_{uv} as well, such as bond types in a molecule. Node vv has neighbors N(v)\mathcal N(v) and degree dv=∣N(v)∣d_v=\abs{\mathcal N(v)}, collected in the diagonal matrix DD.

Three kinds of task recur:

  • Node level: classify each paper in a citation network by topic, or each account as a bot. Often transductive: one large graph, a few labeled nodes, predictions for the rest.
  • Edge level: predict missing or future links, such as which item a user will save next.
  • Graph level: predict a property of a whole graph, such as a molecule's toxicity or energy, from a dataset of many small graphs. Usually inductive: the test graphs were never seen in training.

These requirements rule out the obvious designs. An MLP on the flattened matrix AA can give a different output for each of the up to n!n! numberings of one graph, and it only accepts graphs of one size. Sorting the nodes into a canonical order first does not rescue it: no polynomial-time algorithm is known that computes a canonical order for every graph, and a small edit can reshuffle the order completely. A graph neural network (GNN) instead builds the symmetry into every layer, much as a convolution builds in translations: an inductive bias that removes what need not be learned (Bronstein, Bruna, Cohen & Veličković, 2021).

Check your understanding

Which of these maps a graph's node features XX (rows in node-index order) to a vector that does not depend on how the nodes are numbered?

  1. The first row of XX
  2. All rows of XX concatenated in index order
  3. The sum of the rows of XX
  4. An MLP applied to the flattened adjacency matrix
Show the answer

C. The sum of the rows of XX

Addition is commutative: 1⊤PX=1⊤X\mathbf 1^\top PX=\mathbf 1^\top X for every permutation matrix PP, because 1⊤P=1⊤\mathbf 1^\top P=\mathbf 1^\top. A mean or an elementwise maximum over the rows works for the same reason; these are the readouts of a later step.

Message passing

Almost every GNN fits one template, which Gilmer, Schoenholz, Riley, Vinyals & Dahl (2017) named message passing. At layer ℓ\ell each node vv holds a vector hv(ℓ)\mathbf h_v^{(\ell)}, starting from hv(0)=xv\mathbf h_v^{(0)}=\mathbf x_v. Every edge computes a message, every node combines its incoming messages with a permutation-invariant aggregation such as a sum, and an update function produces the next vector. After LL layers, a readout pools the nodes for graph-level tasks:

mv(ℓ+1)=∑u∈N(v)Mℓ(hv(ℓ),hu(ℓ),euv),hv(ℓ+1)=Uℓ(hv(ℓ),mv(ℓ+1)),y^=R({ ⁣{hv(L):v∈V} ⁣})\mathbf m_v^{(\ell+1)}=\sum_{u\in\mathcal N(v)}M_\ell\big(\mathbf h_v^{(\ell)},\mathbf h_u^{(\ell)},\mathbf e_{uv}\big),\qquad\mathbf h_v^{(\ell+1)}=U_\ell\big(\mathbf h_v^{(\ell)},\mathbf m_v^{(\ell+1)}\big),\qquad\hat y=R\big(\{\!\{\mathbf h_v^{(L)}:v\in V\}\!\}\big)
The message function MℓM_\ell, update UℓU_\ell and readout RR are small networks shared by all nodes and edges, so the number of parameters does not depend on the size of the graph. { ⁣{⋅} ⁣}\{\!\{\cdot\}\!\} denotes a multiset: equal vectors count with their multiplicity.
DerivationWhy message passing is equivariant
  1. H′=ϕ(HW0⊤+AHW1⊤)H'=\phi\big(HW_0^\top+AHW_1^\top\big)

    Take the simplest instance: sum aggregation and linear messages, hv′=ϕ(W0hv+W1∑u∈N(v)hu)\mathbf h_v'=\phi\big(W_0\mathbf h_v+W_1\sum_{u\in\mathcal N(v)}\mathbf h_u\big) with ϕ\phi applied elementwise. With the node vectors as the rows of HH, the neighbor sums are the rows of AHAH:

  2. (PAP⊤)(PH)=P AH(PAP^\top)(PH)=P\,AH

    Relabel the nodes. Because P⊤P=IP^\top P=I, the neighbor sums are relabeled along with the nodes:

  3. ϕ(PHW0⊤+PAHW1⊤)=P ϕ(HW0⊤+AHW1⊤)\phi\big(PHW_0^\top+PAHW_1^\top\big)=P\,\phi\big(HW_0^\top+AHW_1^\top\big)

    An elementwise ϕ\phi commutes with reordering rows, so the layer is equivariant, and so is any stack of such layers. Ending with a sum, mean or max over all nodes makes the whole network invariant. The same argument works for any message, update and aggregation that treat all nodes alike.

Each layer moves information one edge further. After ℓ\ell layers, hv(ℓ)\mathbf h_v^{(\ell)} depends only on the nodes within ℓ\ell hops of vv, its receptive field in the language of convolutions. A layer costs one message per edge and one update per node, O(∣E∣ d+n d2)\order{\abs E\,d+n\,d^2} for width dd and linear maps, so sparse graphs with millions of nodes are cheap to process.

Graph convolutions: GCN, GraphSAGE and GAT

Which messages, and which weights? Three designs from 2017–2018 remain the standard baselines. The first comes from signal processing on graphs.

DerivationFrom spectral filters to the GCN layer (Kipf & Welling, 2017)
  1. gθ⋆x=U gθ(Λ) U⊤xg_{\boldsymbol\theta}\star\mathbf x=U\,g_{\boldsymbol\theta}(\Lambda)\,U^\top\mathbf x

    Treat a node signal x∈Rn\mathbf x\in\R^n like a sound. The normalized Laplacian Δ=I−D−1/2AD−1/2=UΛU⊤\Delta=I-D^{-1/2}AD^{-1/2}=U\Lambda U^\top has eigenvalues in [0,2][0,2], and its eigenvectors play the role of Fourier modes: smooth across edges for small eigenvalues, oscillating for large ones. A spectral filter rescales each mode (Bruna, Zaremba, Szlam & LeCun, 2014), but it needs the eigendecomposition and dense products with UU, O(n2)\order{n^2} per signal:

  2. gθ⋆x≈∑k=0Kθk Tk(Δ~) x,Δ~=2λmax⁡ Δ−Ig_{\boldsymbol\theta}\star\mathbf x\approx\sum_{k=0}^K\theta_k\,T_k(\tilde\Delta)\,\mathbf x,\qquad\tilde\Delta=\frac{2}{\lambda_{\max}}\,\Delta-I

    Make the filter a polynomial of degree KK in Δ\Delta, expanded in Chebyshev polynomials TkT_k for numerical stability (Defferrard, Bresson & Vandergheynst, 2016). Since (Δk)uv=0(\Delta^k)_{uv}=0 whenever uu and vv are more than kk hops apart, the filter is KK-localized, and it costs KK sparse products, O(K∣E∣)\order{K\abs E}:

  3. gθ⋆x≈θ0x−θ1D−1/2AD−1/2x=θ(I+D−1/2AD−1/2)xg_\theta\star\mathbf x\approx\theta_0\mathbf x-\theta_1D^{-1/2}AD^{-1/2}\mathbf x=\theta\big(I+D^{-1/2}AD^{-1/2}\big)\mathbf x

    Keep only K=1K=1, approximate λmax⁡≈2\lambda_{\max}\approx2 (so Δ~=Δ−I=−D−1/2AD−1/2\tilde\Delta=\Delta-I=-D^{-1/2}AD^{-1/2}), and tie the two coefficients, θ=θ0=−θ1\theta=\theta_0=-\theta_1, to leave one parameter per filter:

  4. H(ℓ+1)=ϕ(A^H(ℓ)W(ℓ)),A^=D~−1/2A~D~−1/2,A~=A+I,D~vv=∑uA~uvH^{(\ell+1)}=\phi\big(\hat AH^{(\ell)}W^{(\ell)}\big),\qquad\hat A=\tilde D^{-1/2}\tilde A\tilde D^{-1/2},\quad\tilde A=A+I,\quad\tilde D_{vv}=\textstyle\sum_u\tilde A_{uv}

    This operator has eigenvalues in [0,2][0,2], so applying it layer after layer can blow signals and gradients up or shrink them. The renormalization trick swaps it for the normalized adjacency with self-loops, whose eigenvalues lie in (−1,1](-1,1]. With CC input channels and FF filters, W∈RC×FW\in\R^{C\times F}, this is the graph convolutional network (GCN) layer:

Read entrywise, node vv averages itself and its neighbors with weights 1/(du+1)(dv+1)1/\sqrt{(d_u+1)(d_v+1)}, then applies a shared linear map: the spectral story ends in a very local rule. A two-layer GCN reached 81.5% accuracy on the Cora citation network from 20 labeled papers per class, and the paper's depth experiments found 2 or 3 layers best, with models deeper than 7 layers hard to train without residual connections.

python
import torch

def gcn_norm(edge_index, n):
    """edge_index: (2, E) long tensor listing both directions of every edge."""
    loops = torch.arange(n).repeat(2, 1)
    ei = torch.cat([edge_index, loops], dim=1)            # A + I
    deg = torch.zeros(n).index_add_(0, ei[1], torch.ones(ei.size(1)))
    w = deg[ei[0]].rsqrt() * deg[ei[1]].rsqrt()            # 1 / sqrt(d_u d_v), self-loops counted
    return ei, w

class GCNLayer(torch.nn.Module):
    def __init__(self, d_in, d_out):
        super().__init__()
        self.lin = torch.nn.Linear(d_in, d_out, bias=False)

    def forward(self, x, ei, w):
        h = self.lin(x)                                    # transform first: O(n d_in d_out)
        src, dst = ei
        msg = w[:, None] * h[src]                          # one message per edge: O(|E| d_out)
        out = torch.zeros_like(h).index_add_(0, dst, msg)  # sum the messages at each node
        return torch.relu(out)

A GCN layer written edge by edge. edge_index lists the endpoints of every directed edge and index_add_ sums the messages arriving at each node, so the dense matrix A^\hat A is never formed. Libraries such as PyTorch Geometric and DGL provide these scatter operations, with many layer types built in.

GraphSAGE (Hamilton, Ying & Leskovec, 2017) keeps a node apart from its neighborhood and concatenates the two, hv′=ϕ(W[hv ∥ AGG({hu:u∈S(v)})])\mathbf h_v'=\phi\big(W[\mathbf h_v\,\Vert\,\mathrm{AGG}(\{\mathbf h_u:u\in S(v)\})]\big), then rescales hv′\mathbf h_v' to unit length. The aggregator is a mean, an LSTM run over a random ordering of the neighbors, or an elementwise max after a one-layer network. S(v)S(v) is a fixed-size uniform sample of N(v)\mathcal N(v), drawn afresh for each layer, so the cost of a minibatch no longer depends on the degrees. The model embeds nodes it never saw, even whole new graphs: it is inductive, while the original GCN was trained on one fixed graph.

Predict before you look

In GraphSAGE's experiments a 2-layer model drew a fresh sample of neighbors at each layer: 10 for the second layer and 25 for the first. Each update also uses the node's own vector from the layer below. At most how many nodes, the target included, enter the computation of one embedding?

Show the answer

286 nodes

The target's second-layer update needs the first-layer vectors of the target itself and of its 10 sampled neighbors, and each of those 11 vectors aggregates its own sample of 25: at most 1+10+11×25=2861+10+11\times25=286 nodes, whatever the degrees (1+10+10×25=2611+10+10\times25=261 forgets the target's own first-layer sample). Their Reddit graph had 232,965 posts with an average degree of 492: without sampling, the 2-hop computation tree of an average post would have about 1+492+4922≈242,6001+492+492^2\approx242{,}600 entries, more than the graph has nodes. (The paper names the sizes by layer, S1=25S_1=25 and S2=10S_2=10, and its minibatch algorithm expands from the target with the 10 first.)

A graph attention network (GAT; Veličković et al., 2018) lets each node weight its neighbors with learned attention, like self-attention restricted to the graph's edges:

euv=LeakyReLU⁡(a⊤[Whu ∥ Whv]),αuv=exp⁡(euv)∑w∈N(u)∪{u}exp⁡(euw),hu′=ϕ(∑v∈N(u)∪{u}αuvWhv)e_{uv}=\operatorname{LeakyReLU}\big(\mathbf a^\top[W\mathbf h_u\,\Vert\,W\mathbf h_v]\big),\qquad\alpha_{uv}=\frac{\exp(e_{uv})}{\sum_{w\in\mathcal N(u)\cup\{u\}}\exp(e_{uw})},\qquad\mathbf h_u'=\phi\Big(\sum_{v\in\mathcal N(u)\cup\{u\}}\alpha_{uv}W\mathbf h_v\Big)
The LeakyReLU has slope 0.2 for negative inputs, and the softmax runs over the node's neighbors and itself. GAT runs several heads and concatenates them, averaging in the output layer instead; with 8 heads of 8 features in its first layer it reached 83.0% on Cora.

Brody, Alon & Yahav (2022) found a limitation hidden in that score. Split a=[a1;a2]\mathbf a=[\mathbf a_1;\mathbf a_2]: then euv=LeakyReLU⁡(a1⊤Whu+a2⊤Whv)e_{uv}=\operatorname{LeakyReLU}(\mathbf a_1^\top W\mathbf h_u+\mathbf a_2^\top W\mathbf h_v), and since LeakyReLU and softmax are increasing, every query ranks the nodes by the same number a2⊤Whv\mathbf a_2^\top W\mathbf h_v; the query only sharpens or flattens the distribution. They call this static attention. GATv2 swaps the order of operations, euv=a⊤LeakyReLU⁡(W[hu∥hv])e_{uv}=\mathbf a^\top\operatorname{LeakyReLU}(W[\mathbf h_u\Vert\mathbf h_v]), so the score is a small MLP of the pair and each query can rank its neighbors differently; in their evaluation GATv2 outperformed GAT across 11 OGB and other benchmarks at matched parameter cost.

LayerWeight on neighbor vv in node uu's updateThe node itselfKnown for
GCN1/(du+1)(dv+1)1/\sqrt{(d_u+1)(d_v+1)}, fixed by the degreesthrough the self-loopspectral derivation; semi-supervised node classification
GraphSAGE (mean)1/∣S(u)∣1/\abs{S(u)} over a sampled setconcatenated separatelyinductive minibatch training on large graphs
GATαuv\alpha_{uv}, a softmax of learned scoresinside the softmaxdifferent weights for different neighbors
GIN11 (a plain sum), followed by an MLP(1+ϵ) hu(1+\epsilon)\,\mathbf h_uthe most discriminative message passing (The Expressive Power of GNNs)
All four are message passing with different aggregation weights. A sum keeps counts, a degree-normalized average does not, and which one a task needs is part of the next lessons.

From nodes to whole graphs

For a graph-level prediction, a readout pools the final node vectors into one vector, and it must be permutation-invariant. The simplest readouts are a sum, a mean or an elementwise max over the nodes, followed by an MLP. That is exactly the architecture of Deep Sets for functions of sets (Zaheer et al., 2017):

f(X)=ρ(∑x∈Xϕ(x))f(X)=\rho\Big(\sum_{\mathbf x\in X}\phi(\mathbf x)\Big)
Zaheer et al. proved that every permutation-invariant function of sets drawn from a countable universe has this form; for continuous inputs they could prove it only for sets of a fixed size. They also showed that a linear map on a set of MM numbers is permutation-equivariant exactly when it equals λI+γ11⊤\lambda I+\gamma\mathbf 1\mathbf 1^\top: each element keeps a share of itself and receives a share of the total.

The choice of pooling matters. A sum keeps counts: two carbon atoms contribute twice as much as one. A mean keeps only proportions, so a molecule and two copies of it get the same vector. A max keeps only which feature values occur at all. Gilmer et al. also used set2set, an attention-based pooling, and a virtual node (their "master node") joined to every node, which gives every pair of nodes a 2-hop connection and the network a global scratch space.

Hierarchical pooling coarsens the graph step by step, like the pooling layers of a CNN. DiffPool (Ying et al., 2018) learns a soft assignment of the nn nodes to c<nc<n clusters with a second GNN, whose output passes through a softmax in each row:

S=softmax⁡(GNNpool(A,X))∈Rn×c,X′=S⊤Z,A′=S⊤ASS=\softmax\big(\mathrm{GNN}_{\text{pool}}(A,X)\big)\in\R^{n\times c},\qquad X'=S^\top Z,\qquad A'=S^\top AS
Z=GNNembed(A,X)Z=\mathrm{GNN}_{\text{embed}}(A,X) holds node embeddings from a separate GNN. The coarsened graph has cc nodes, features X′X' and weighted adjacency A′A', and the step repeats on it. Everything is differentiable, so the clustering is learned from the graph-level loss.
Check your understanding

You predict the total energy of molecules of very different sizes. Total energy is extensive: it grows roughly in proportion to the number of atoms. Which readout fits best?

  1. The mean over atoms
  2. The max over atoms
  3. The sum over atoms
  4. The vector of the first atom
Show the answer

C. The sum over atoms

A sum of per-atom contributions, E=∑iEiE=\sum_iE_i, scales with the number of atoms as the target does. SchNet and the interatomic potentials of Equivariant Networks for 3D Geometry pool atomwise energies in exactly this way.

Depth, scale and where GNNs are used

Depth sets the receptive field, so long-range tasks seem to call for deep GNNs. Yet most GNNs use two to a handful of layers, for two reasons that the Emergence lessons develop. Repeated averaging drives all node vectors in a connected graph toward one another until neighbors are indistinguishable, oversmoothing: keep adding mean layers in the widget above and the club's energy falls below 5% of its start by layer 6, as the Activation lesson's two communities also showed. And when a node's receptive field grows exponentially with depth while its vector keeps a fixed size, information from far away is squeezed through a few edges, oversquashing.

Scale brings an engineering version of the same problem: a kk-layer computation reaches the whole kk-hop neighborhood, which in a social graph can be a large part of the graph. Sampling, as in GraphSAGE, and precomputing propagated features are the usual fixes.

Key takeaways

  • Graphs have no node order: node-level layers must be permutation-equivariant, F(PAP⊤,PX)=P F(A,X)F(PAP^\top,PX)=P\,F(A,X), and graph-level readouts invariant. Message passing with shared functions and a sum, mean or max over neighbors has both properties.
  • A message-passing layer computes one message per edge, aggregates per node and updates per node, at a cost of O(∣E∣ d+n d2)\order{\abs E\,d+n\,d^2}; ℓ\ell layers see exactly the ℓ\ell-hop neighborhood.
  • GCN is a first-order spectral filter with the renormalization trick, H′=ϕ(D~−1/2A~D~−1/2HW)H'=\phi(\tilde D^{-1/2}\tilde A\tilde D^{-1/2}HW); GraphSAGE concatenates a node with an aggregate of sampled neighbors for inductive minibatch training; GAT learns attention weights over neighbors, though its scores rank the neighbors in the same order for every query.
  • Graph-level predictions pool node vectors with a sum, mean or max (Deep Sets' ρ(∑ϕ)\rho(\sum\phi)) or hierarchically with learned clusters; a sum keeps counts and extensive quantities, a mean only proportions.
  • Most GNNs use a few layers: depth widens the receptive field but brings oversmoothing and oversquashing. GNNs have documented results on molecules, recommendation, physical simulation, weather, traffic and protein structure.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Relabeling the nodes replaces (A,X)(A,X) by (PAP⊤,PX)(PAP^\top,PX). A GNN layer FF outputs one vector per node. Which property must it have?

  1. F(PAP⊤,PX)=F(A,X)F(PAP^\top,PX)=F(A,X)
  2. F(PAP⊤,PX)=P F(A,X)F(PAP^\top,PX)=P\,F(A,X)
  3. F(PA,PX)=P F(A,X)F(PA,PX)=P\,F(A,X)
  4. F(A,PX)=P F(A,X)F(A,PX)=P\,F(A,X)
Show the answer

B. F(PAP⊤,PX)=P F(A,X)F(PAP^\top,PX)=P\,F(A,X)

Node outputs must move with their nodes: equivariance. Message passing has it because every node runs the same computation on its own vector and the multiset of its neighbors' vectors.

Question 2

Why does the GCN layer propagate with D~−1/2(A+I)D~−1/2\tilde D^{-1/2}(A+I)\tilde D^{-1/2} rather than the first-order filter I+D−1/2AD−1/2I+D^{-1/2}AD^{-1/2}?

  1. Adding self-loops makes the adjacency matrix sparser
  2. It turns the layer into an attention mechanism
  3. The renormalized matrix has eigenvalues in (−1,1](-1,1] instead of [0,2][0,2], so repeated propagation cannot amplify any component of the signal
  4. It makes each layer reach two hops instead of one
Show the answer

C. The renormalized matrix has eigenvalues in (−1,1](-1,1] instead of [0,2][0,2], so repeated propagation cannot amplify any component of the signal

The first-order filter's eigenvalues reach 22, so LL layers can amplify some components by up to 2L2^L; Kipf & Welling noted that repeated application can cause numerical instabilities and exploding or vanishing gradients. Renormalizing with self-loops keeps the spectrum in (−1,1](-1,1] while still mixing each node with its neighbors.

Question 3

The information needed to classify node vv sits only at nodes 6 hops away. What can a 2-layer message-passing GNN do with it?

  1. Use it after enough training epochs
  2. Nothing: vv's output depends only on nodes within 2 hops
  3. Use it through the self-loops
  4. Use it if the aggregation is a sum rather than a mean
Show the answer

B. Nothing: vv's output depends only on nodes within 2 hops

Each layer extends the receptive field by one hop, so a 2-layer network computes vv's output from its 2-hop neighborhood alone. Reaching 6 hops needs 6 layers, or a change to the graph such as a virtual node joined to every node.

Question 4

In a GAT layer the score of neighbor vv for query uu is LeakyReLU⁡(a1⊤Whu+a2⊤Whv)\operatorname{LeakyReLU}(\mathbf a_1^\top W\mathbf h_u+\mathbf a_2^\top W\mathbf h_v). What follows?

  1. Every query ranks its candidate neighbors in the same order, by a2⊤Whv\mathbf a_2^\top W\mathbf h_v
  2. Each query can rank its neighbors in whatever order the task needs
  3. All neighbors always receive equal weights
  4. The attention weights of a node need not sum to one
Show the answer

A. Every query ranks its candidate neighbors in the same order, by a2⊤Whv\mathbf a_2^\top W\mathbf h_v

The query enters only through the shift a1⊤Whu\mathbf a_1^\top W\mathbf h_u, the same for all candidates, and LeakyReLU and softmax are increasing. So the order of the scores is global; the query only sharpens or flattens the weights. Brody, Alon & Yahav (2022) call this static attention, and GATv2 removes it by applying a\mathbf a after the nonlinearity.

Question 5

Why does GraphSAGE sample a fixed number of neighbors per node and layer instead of using all of them?

  1. Sampling makes the network exactly as powerful as the Weisfeiler–Leman test
  2. A mean over a large neighborhood is undefined
  3. Sampling makes the embeddings invariant to how the nodes are numbered
  4. To keep the cost and memory of a minibatch bounded whatever the degrees, since full multi-hop neighborhoods can cover much of a large graph
Show the answer

D. To keep the cost and memory of a minibatch bounded whatever the degrees, since full multi-hop neighborhoods can cover much of a large graph

With samples of 10 and 25, one embedding involves at most 286 nodes, while the full 2-hop computation tree of an average Reddit post in their data would have more entries than the graph has nodes. The price is noise from sampling, which training tolerates, and the gain is minibatch training on graphs of any size.

Go deeper

Further reading

  • J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals & G. E. Dahl, "Neural message passing for quantum chemistry," ICML (2017).
  • T. N. Kipf & M. Welling, "Semi-supervised classification with graph convolutional networks," ICLR (2017).
  • W. L. Hamilton, R. Ying & J. Leskovec, "Inductive representation learning on large graphs," NeurIPS (2017).
  • P. Veličković, G. Cucurull, A. Casanova, A. Romero, P. Liò & Y. Bengio, "Graph attention networks," ICLR (2018).
  • W. L. Hamilton, Graph Representation Learning (Morgan & Claypool, 2020).