Theory · Graph neural networks

GIN: How Powerful are Graph Neural Networks?

Summing neighbor features instead of averaging them lets a graph network tell apart every pair of graphs that a classic isomorphism test can.

Xu, Hu, Leskovec and Jegelka prove that a graph neural network that updates each node from its neighbors can give two graphs different embeddings only when the Weisfeiler-Lehman test also separates them. Averaging or taking the maximum over neighbors, as GCN and GraphSAGE do, falls short of that limit on small, simple graphs. The Graph Isomorphism Network (GIN) reaches it with a sum followed by a multi-layer perceptron.

Explaining the paperHow Powerful are Graph Neural Networks?Keyulu Xu, Weihua Hu, Jure Leskovec, Stefanie Jegelka · ICLR 2019 · arXiv:1810.00826 ↗

On REDDIT-BINARY, where every node carries the same feature and only the shape of a discussion thread can identify its subreddit, the two mean-aggregating models score 50.0% with a standard deviation of 0.0, chance for two classes. GIN scores 92.4%.

What "powerful" means for a graph neural network

A graph neural network (GNN) turns a graph into vectors: one per node, and for tasks like "is this molecule toxic" one per graph. In 2018 there were many designs, among them GCN, GraphSAGE and GAT, chosen mostly by trying them. This paper asks a question that does not depend on data or training: given two graphs that are not the same, can the network give them different vectors at all?

The question matters because the classifier downstream receives only the vector. If a GNN maps two different graphs to the same vector for every setting of its weights, it must give them the same prediction, whatever their true labels are, and no amount of training fixes that. The paper measures a GNN's power by the set of graph pairs it can map to different vectors with some setting of its weights: the larger that set, the more powerful the GNN.

The answer comes in four parts:

  1. an upper bound: no GNN of the usual message-passing kind separates more pairs than a 1968 heuristic for graph isomorphism, the Weisfeiler-Lehman (WL) test;
  2. a condition for reaching the bound: the step that combines a node's neighbors must be injective on multisets (two different collections of neighbor vectors must never produce the same output), and so must the step that pools nodes into a graph vector;
  3. a diagnosis: mean and max aggregation are not injective, and a single linear layer with ReLU is not enough, so GCN and GraphSAGE sit below the bound;
  4. a model, GIN, that meets the condition with a sum and a multi-layer perceptron, and its results on nine benchmarks.

How message passing works

A graph G=(V,E)G = (V, E) has nodes VV, edges EE, and a feature vector XvX_v on each node vv: in a molecule, a one-hot vector for the atom type; in a social network with no node data, a constant or the node's degree. N(v)\mathcal{N}(v) is the set of nodes adjacent to vv. A GNN keeps a vector hv(k)h_v^{(k)} per node, starting from hv(0)=Xvh_v^{(0)} = X_v, and each layer kk updates every node from its neighbors:

av(k)=AGGREGATE(k)({hu(k−1):u∈N(v)}),hv(k)=COMBINE(k)(hv(k−1),av(k))a_v^{(k)} = \text{AGGREGATE}^{(k)}\big(\{h_u^{(k-1)} : u \in \mathcal{N}(v)\}\big), \qquad h_v^{(k)} = \text{COMBINE}^{(k)}\big(h_v^{(k-1)}, a_v^{(k)}\big)av(k)=AGGREGATE(k)({hu(k−1):u∈N(v)}),hv(k)=COMBINE(k)(hv(k−1),av(k))\begin{gathered} a_v^{(k)} = \text{AGGREGATE}^{(k)}\big(\{h_u^{(k-1)} : u \in \mathcal{N}(v)\}\big), \\ h_v^{(k)} = \text{COMBINE}^{(k)}\big(h_v^{(k-1)}, a_v^{(k)}\big) \end{gathered}
(2.1)

AGGREGATE reduces the neighbors' vectors to one vector av(k)a_v^{(k)}; COMBINE merges it with the node's own previous vector. Both must ignore the order in which neighbors are listed, because a graph has no canonical node order. Gilmer et al. (2017) showed that many earlier models fit this template and named it message passing, in the MPNN framework. After kk layers, hv(k)h_v^{(k)} depends on everything within kk hops of vv. GraphSAGE's pooling variant aggregates with an element-wise maximum and combines by concatenating the two vectors and applying a linear map:

av(k)=MAX({ReLU(W⋅hu(k−1)), ∀u∈N(v)})a_v^{(k)} = \text{MAX}\big(\{\text{ReLU}(W \cdot h_u^{(k-1)}),\ \forall u \in \mathcal{N}(v)\}\big)av(k)=MAX({ReLU(W⋅hu(k−1)),∀u∈N(v)})\begin{aligned} a_v^{(k)} = \text{MAX}\big(\{&\text{ReLU}(W \cdot h_u^{(k-1)}), \\ &\forall u \in \mathcal{N}(v)\}\big) \end{aligned}
(2.2)

The paper writes GCN as an element-wise mean over the node and its neighbors, folded into one step:

hv(k)=ReLU(W⋅MEAN{hu(k−1), ∀u∈N(v)∪{v}})h_v^{(k)} = \text{ReLU}\big(W \cdot \text{MEAN}\{h_u^{(k-1)},\ \forall u \in \mathcal{N}(v) \cup \{v\}\}\big)hv(k)=ReLU(W⋅MEAN{hu(k−1),∀u∈N(v)∪{v}})\begin{aligned} h_v^{(k)} = \text{ReLU}\big(W \cdot \text{MEAN}\{&h_u^{(k-1)}, \\ &\forall u \in \mathcal{N}(v) \cup \{v\}\}\big) \end{aligned}
(2.3)

(Kipf and Welling's actual GCN weights each neighbor by 1/d~ud~v1/\sqrt{\tilde d_u \tilde d_v}, the degrees counted with self-loops, which is close to a mean but not equal to one; the Provenance panel works out where that matters.) For graph classification, a READOUT pools the final node vectors into one graph vector, for example by summing them:

hG=READOUT({hv(K)∣v∈G})h_G = \text{READOUT}\big(\{h_v^{(K)} \mid v \in G\}\big)
(2.4)

A worked example shows where the aggregator choice bites. Give nodes one of two types with one-hot features a=(1,0)a = (1, 0) and b=(0,1)b = (0, 1). Node vv has type aa and two neighbors, one aa and one bb. Node v′v' has type aa and five neighbors, three aa and two bb. The mean in (2.3) runs over the node and its neighbors:

MEAN(v)=13(2,1)=(0.67,0.33),MEAN(v′)=16(4,2)=(0.67,0.33)\text{MEAN}(v) = \tfrac{1}{3}(2, 1) = (0.67, 0.33), \qquad \text{MEAN}(v') = \tfrac{1}{6}(4, 2) = (0.67, 0.33)MEAN(v)=13(2,1)=(0.67,0.33),MEAN(v′)=16(4,2)=(0.67,0.33)\begin{gathered} \text{MEAN}(v) = \tfrac{1}{3}(2, 1) = (0.67, 0.33), \\ \text{MEAN}(v') = \tfrac{1}{6}(4, 2) = (0.67, 0.33) \end{gathered}

The two vectors are identical before WW is applied, so hv(1)=hv′(1)h_v^{(1)} = h_{v'}^{(1)} for every weight matrix: no amount of training lets layer 1 separate these two nodes. A sum over the same sets gives (2,1)(2, 1) and (4,2)(4, 2), which differ.

The Weisfeiler-Lehman test

Two graphs are isomorphic when the nodes of one can be renamed to give exactly the other: same nodes, same edges, only the labels differ. No polynomial-time algorithm for deciding this is known. The Weisfeiler-Lehman test, in its 1-dimensional form also called color refinement, is a fast heuristic that answers "different" or "don't know":

  1. Give every node a color: its label if nodes have labels, otherwise the same color for all.
  2. Each round, replace each node's color with a new one that encodes the pair (its current color, the multiset of its neighbors' current colors). The encoding is injective: two nodes get the same new color only if their pairs are identical. Both graphs share one table of new colors.
  3. After each round, compare how many nodes of each color the two graphs have. If the counts differ, the graphs are not isomorphic, since renaming nodes cannot change a count.
  4. If the counts are still equal when a round produces no new color split, the test stops without a verdict.

On a path of 4 nodes and a star of 4 nodes (one center joined to three leaves), round 1 replaces the uniform color with one that amounts to the degree: the path has two nodes of degree 1 and two of degree 2, the star one of degree 3 and three of degree 1. The counts differ after one round. Harder pairs need more rounds, because a color at round kk summarizes the node's whole neighborhood out to kk hops: unrolled, it is a tree of height kk rooted at the node, with the node's neighbors as children, their neighbors as grandchildren, and so on (nodes can repeat in the tree). The WL subtree kernel of Shervashidze et al. (2011) uses the counts of these colors directly as a graph's feature vector, and it is the strongest baseline in the paper's experiments.

Figure 1 runs the test on four pairs. Watch the color counts under each graph, and click a node to see the pair its color encodes.

Figure 1 · color refinement on four pairs
round 0
Pick a pair, then press Play or drag the round slider. Node colors are shared across both graphs; the dots under each graph count its nodes of each color. Click a node, or focus the canvas and use the arrow keys, to read its color as (previous color, previous colors of its neighbors). "Same degrees" separates only at round 2; the last two pairs never separate.

The "same degrees" pair, a triangle with two tails against a square with two pendant nodes, has degrees 1, 1, 2, 2, 3, 3 in both graphs, so round 1 gives identical counts. In round 2 each degree-3 node's new color records its neighbors' degrees: in the triangle graph one degree-3 node has neighbors of degree 2, 2, 3 and the other 1, 2, 3, while in the square graph both have neighbors of degree 1, 2, 3, so the round-2 counts differ.

The hexagon and the two triangles never separate. Every node in both has degree 2 and two neighbors of degree 2, so every node keeps one color forever, yet one graph has two triangles and the other none. The same happens for any two regular graphs (all nodes of equal degree) with the same size and degree. Decalin and bicyclopentyl, two hydrocarbon skeletons with 10 carbons and 11 bonds each, are a non-regular case: both stabilize at round 2 with 2 nodes of degree 3, 4 nodes next to them and 4 farther away. Cai, Fürer and Immerman (1992) built families of graph pairs that defeat this test and its higher-dimensional versions as well.

The test runs fast because colors only ever split: the new color includes the old one, so two nodes with different colors never merge. A graph of nn nodes can carry at most nn colors, so the refinement stops changing within n−1n - 1 rounds.

Why no GNN beats the WL test

Read the update (2.1) next to the WL step and they have the same shape: a function of (own value, multiset of neighbor values). The WL step uses an injective encoding. A GNN layer uses whatever AGGREGATE and COMBINE compute, which can only merge distinct inputs, never split identical ones. That gives Lemma 2:

Let G1G_1 and G2G_2 be any two non-isomorphic graphs. If a graph neural network A:G→Rd\mathcal{A}: \mathcal{G} \to \mathbb{R}^d maps G1G_1 and G2G_2 to different embeddings, the Weisfeiler-Lehman graph isomorphism test also decides G1G_1 and G2G_2 are not isomorphic.

The proof in Appendix A is an induction over layers, assuming the GNN and the test start from the same features:

  1. At layer 0, nodes with the same WL color have the same input feature, so the same h(0)h^{(0)}.
  2. Suppose nodes with equal WL colors at round jj have equal GNN vectors at layer jj. Two nodes with the same color at round j+1j + 1 had the same color and the same multiset of neighbor colors at round jj, because the WL encoding is injective. By the assumption they then had the same own vector and the same multiset of neighbor vectors, and the same AGGREGATE and COMBINE applied to the same inputs give the same h(j+1)h^{(j+1)}.
  3. So each hv(k)h_v^{(k)} is a function of the WL color of vv. If the two graphs have equal color counts at round kk, they have equal multisets of node vectors, and any readout that ignores node order returns the same graph vector.

For the hexagon and the two triangles with constant input features, every GCN, GraphSAGE, GAT or GIN of the form (2.1) returns the same graph vector for both, whatever its weights, depth or width, so no such network can be trained to output their triangle counts, 0 and 2.

Neighborhoods are multisets: sum vs mean vs max

Lemma 2 is an upper bound. To reach it, a GNN must lose nothing that the WL encoding keeps. The input to AGGREGATE is the collection of neighbor vectors, and several neighbors can carry identical vectors, so the collection is a multiset: a set in which an element can occur more than once. The paper defines a multiset as a pair X=(S,m)X = (S, m), where SS is the underlying set of distinct elements and m:S→N≥1m: S \to \mathbb{N}_{\ge 1} gives each element's multiplicity; for {a,a,b}\{a, a, b\}, S={a,b}S = \{a, b\}, m(a)=2m(a) = 2 and m(b)=1m(b) = 1.

Theorem 3 states the condition. A GNN reaches the WL bound, given enough layers, if it updates nodes as

hv(k)=ϕ(hv(k−1), f({hu(k−1):u∈N(v)}))h_v^{(k)} = \phi\Big(h_v^{(k-1)},\ f\big(\{h_u^{(k-1)} : u \in \mathcal{N}(v)\}\big)\Big)hv(k)=ϕ(hv(k−1),f({hu(k−1):u∈N(v)}))\begin{aligned} h_v^{(k)} = \phi\Big(&h_v^{(k-1)}, \\ &f\big(\{h_u^{(k-1)} : u \in \mathcal{N}(v)\}\big)\Big) \end{aligned}

with ff (on multisets) and ϕ\phi both injective, and if its graph readout is injective on the multiset of node vectors. The proof (Appendix B) runs Lemma 2's induction in the other direction: with injective steps, hv(k)h_v^{(k)} is an injective function of the WL color, so different color counts give different multisets of node vectors, and an injective readout keeps them apart.

Which aggregators are injective on multisets? Figure 2 compares the three in use on two neighborhoods. Each neighbor has a one-hot type vector, so the sum is the vector of counts, the mean is the vector of proportions, and the max marks which types occur. A learned transformation applied before aggregating cannot do better than this for mean or max: their collisions below happen for any choice of per-neighbor function.

Figure 2 · three aggregators on two neighborhoods
va×0b×1c×1
v'a×0b×2c×1
Use the presets (the three pairs from the paper's Figure 3) or the − and + buttons to build the neighbor multisets of vv and v′v'. Each row shows one aggregator's output for both nodes; collide means the two outputs are equal, differ means they are not.

The three presets match the paper's Figure 3. In 3a every node has the same feature, vv has two neighbors and v′v' three: the mean and max of identical vectors equal that vector, so both collide, while the sum gives 2f(a)2 f(a) against 3f(a)3 f(a). In 3b, vv has one neighbor of each of two types and v′v' has one of the first and two of the second: max collides, since the same types occur, but mean differs (12\tfrac12 and 12\tfrac12 against 13\tfrac13 and 23\tfrac23). In 3c, v′v' has two of each: the proportions match too, and only sum separates them.

Case 3a has a consequence for whole graphs. When every node starts with the same feature, a mean or max layer returns that same vector at every node, at every depth. With the mean readout used on the social datasets, the graph vector is that vector too, so the network computes the same output for every unlabeled graph, whatever its structure. That predicts the 50.0% and 20.0% (chance) that the mean models score on REDDIT-BINARY and REDDIT-MULTI5K, where all nodes share one feature. (A sum readout would still pass on the node count.)

Corollaries 8 and 9 characterize exactly what each aggregator keeps. For the mean,

h(X)=1∣X∣∑x∈Xf(x)h(X) = \frac{1}{|X|} \sum_{x \in X} f(x)

can be made to collide only when X1=(S,m)X_1 = (S, m) and X2=(S,k⋅m)X_2 = (S, k \cdot m): the same elements with all multiplicities scaled by an integer k≥1k \ge 1. Mean keeps the distribution of the multiset. For the max, h(X)=max⁡x∈Xf(x)h(X) = \max_{x \in X} f(x) can be made to collide only when the two multisets have the same underlying set SS. Max keeps which elements are present. Sum, with a suitable ff, keeps the whole multiset, as the next section shows.

How a sum can be injective

A sum of raw feature vectors is not injective in general: with scalar features, {1,3}\{1, 3\} and {2,2}\{2, 2\} both sum to 4. Lemma 5 says a transformation ff applied to each element before summing fixes that:

Assume X\mathcal{X} is countable. There exists a function f:X→Rnf: \mathcal{X} \to \mathbb{R}^n so that h(X)=∑x∈Xf(x)h(X) = \sum_{x \in X} f(x) is unique for each multiset X⊂XX \subset \mathcal{X} of bounded size. Moreover, any multiset function gg can be decomposed as g(X)=ϕ(∑x∈Xf(x))g(X) = \phi\big(\sum_{x \in X} f(x)\big) for some function ϕ\phi.

The construction in Appendix D writes the sum as a number in base NN. "Countable" means the possible features can be numbered, Z:X→NZ: \mathcal{X} \to \mathbb{N}, which holds for one-hot labels, for degrees, and, by Lemma 4, for the hidden vectors a fixed network computes from such inputs. "Bounded size" means every multiset has fewer than NN elements, as when node degree is bounded. Then set

f(x)=N−Z(x)f(x) = N^{-Z(x)}

and the sum, written in base NN, has the count of feature number ii as its ii-th digit after the point. With N=4N = 4 and three atom types numbered C = 1, O = 2, S = 3, the neighborhood {C,C,S}\{C, C, S\} sums to

2⋅4−1+0⋅4−2+1⋅4−3=0.515625=0.20142 \cdot 4^{-1} + 0 \cdot 4^{-2} + 1 \cdot 4^{-3} = 0.515625 = 0.201_{4}

and reading the digits 2, 0, 1 back gives the multiset. No count can reach 4 when the multiset has fewer than 4 elements, so no digit carries and every multiset gets its own number. The second claim of the lemma follows: since the sum identifies the multiset, any function gg of the multiset can be computed by a function ϕ\phi of the sum. Figure 3 lets you break the size bound.

Figure 3 · the sum as base-N digits
C×2O×0S×1
base NN = 4
Set the neighbor counts with − and +, and the base NN with the slider. While every count is below NN, the digits of the sum are the counts. Push a count to NN or more and its digit carries; the figure then searches for a different multiset with the same sum and shows it.

With N=4N = 4, four O neighbors sum to 4⋅4−2=4−14 \cdot 4^{-2} = 4^{-1}, the same value as a single C neighbor, so the multisets {O,O,O,O}\{O, O, O, O\} and {C}\{C\} get the same sum. The bound on multiset size rules this out. Zaheer et al.'s Deep Sets (2017) proved the same decomposition, ρ(∑xϕ(x))\rho\big(\sum_x \phi(x)\big), for sets, where every multiplicity is 0 or 1, with 4−c(x)4^{-c(x)} in the proof; GIN's lemma extends it to multisets.

The node's own vector has to be kept apart from its neighbors'. The simplest way, adding f(c)f(c) for the center node cc into the same sum, fails: a node of type aa with one neighbor of type bb and a node of type bb with one neighbor of type aa both get f(a)+f(b)f(a) + f(b). Corollary 6 weights the center by 1+ϵ1 + \epsilon:

h(c,X)=(1+ϵ)⋅f(c)+∑x∈Xf(x)h(c, X) = (1 + \epsilon) \cdot f(c) + \sum_{x \in X} f(x)

This is unique for every pair (node, neighbor multiset) when ϵ\epsilon is irrational. With the digit construction, every ff value is rational. If two pairs with different centers cc and c′c' collided, rearranging gives ϵ⋅(f(c)−f(c′))\epsilon \cdot (f(c) - f(c')) on one side, an irrational number, and a finite sum of rationals on the other, which is rational (Appendix E, Eq. E.1). Pairs with the same center reduce to Lemma 5. In the example, ϵ=0.5\epsilon = 0.5 gives the aa node 1.5f(a)+f(b)1.5 f(a) + f(b) and the bb node f(a)+1.5f(b)f(a) + 1.5 f(b). Concatenating the center vector with the neighbor sum would satisfy Theorem 3 as well; the ϵ\epsilon form keeps one vector of fixed width going into the next MLP.

How GIN works

GIN puts Corollary 6 into a layer. The functions ff and φ\varphi exist; the network learns them with multi-layer perceptrons (MLPs), which can approximate any continuous function on a bounded domain (Hornik et al., 1989; Hornik, 1991). Since layer kk applies φ(k)\varphi^{(k)} and layer k+1k + 1 then applies f(k+1)f^{(k+1)} to the result before its sum, one MLP per layer models the composition f(k+1)∘φ(k)f^{(k+1)} \circ \varphi^{(k)}:

hv(k)=MLP(k)((1+ϵ(k))⋅hv(k−1)+∑u∈N(v)hu(k−1))h_v^{(k)} = \text{MLP}^{(k)}\Big(\big(1 + \epsilon^{(k)}\big) \cdot h_v^{(k-1)} + \sum_{u \in \mathcal{N}(v)} h_u^{(k-1)}\Big)hv(k)=MLP(k)((1+ϵ(k))⋅hv(k−1)+∑u∈N(v)hu(k−1))\begin{aligned} h_v^{(k)} = \text{MLP}^{(k)}\Big(&\big(1 + \epsilon^{(k)}\big) \cdot h_v^{(k-1)} \\ &+ \sum_{u \in \mathcal{N}(v)} h_u^{(k-1)}\Big) \end{aligned}
(4.1)

The first layer needs no MLP before its sum when the inputs are one-hot, because a sum of one-hot vectors is already the count vector. ϵ(k)\epsilon^{(k)} is either learned by gradient descent (GIN-ε) or fixed at 0 (GIN-0). GIN-0 adds the node to its own neighbor sum, the failure case above, so it is slightly less powerful in theory; the paper's footnote 2 calls the graphs that only GIN-ε separates "somewhat contrived".

For graph classification, the readout uses every depth. Node vectors become more global as layers are added, and enough layers are needed to separate graphs, but the authors report that features from earlier layers sometimes generalize better. Following Jumping Knowledge networks, GIN reads out each layer and concatenates:

hG=CONCAT(READOUT({hv(k)∣v∈G})  ∣  k=0,1,…,K)h_G = \text{CONCAT}\Big(\text{READOUT}\big(\{h_v^{(k)} \mid v \in G\}\big) \;\Big|\; k = 0, 1, \ldots, K\Big)hG=CONCAT(READOUT({hv(k)∣v∈G})∣  k=0,1,…,K)\begin{aligned} h_G = \text{CONCAT}\Big(&\text{READOUT}\big(\{h_v^{(k)} \mid v \in G\}\big) \\ &\Big|\; k = 0, 1, \ldots, K\Big) \end{aligned}
(4.2)

With a sum as READOUT, the graph vector at each depth is injective on the multiset of node vectors, by the same lemma, and the model generalizes both the WL test and the WL subtree kernel, which counts colors at every round. Here is one forward and backward pass on MUTAG (188 molecules, 7 atom types, 2 classes) at the code's default width of 64 (the paper's test runs tuned 16 or 32 on the bioinformatics datasets):

# GIN-0 forward pass on one MUTAG minibatch, as in the official code
# 32 graphs stacked into one big graph of n nodes (about 32 x 17.9 = 573)
# A: n x n sparse adjacency, block-diagonal; X: n x 7 one-hot atom types
# P: 32 x n pooling matrix, P[g, v] = 1 if node v belongs to graph g
A_hat = A + I                          # GIN-0: (1 + 0) * h_v + sum of neighbors
h, reps = X, [X]
for k in range(4):                     # num_layers=5 counts the input: 4 updates
    z = A_hat @ h                      # n x 7, later n x 64: the sum in (4.1)
    z = lin2(relu(bn1(lin1(z))))       # the 2-layer MLP of (4.1)
    h = relu(bn_out(z))                # n x 64
    reps.append(h)
logits = 0
for head, r in zip(heads, reps):       # 5 depths: k = 0, 1, 2, 3, 4
    logits += dropout(head(P @ r), 0.5)  # sum readout per depth, then 32 x 2
loss = cross_entropy(logits, y)        # y: 32 labels, mutagenic or not
loss.backward()                        # reaches every MLP, BatchNorm and head

Batching 32 graphs into one block-diagonal adjacency matrix means the sum aggregation for the whole batch is one sparse matrix product, A_hat @ h, and the graph readout is another, P @ r. Summing five per-depth linear heads equals one linear layer on the concatenation in (4.2), with inputs of width 7 + 4 × 64 = 263. Gradients reach every weight: the four MLPs, the batch normalization layers after each linear map, and the five heads, 31,192 parameters in all. GIN-ε changes one line:

# GIN-eps: the adjacency has no self-loops; each layer has its own eps
z = A @ h + (1 + eps[k]) * h           # eps = nn.Parameter(torch.zeros(4))

Training uses Adam at learning rate 0.01, halved every 50 epochs, with dropout of 0 or 0.5 on the heads (tuned per dataset); the code defaults to 350 epochs of 50 minibatches each. Each layer costs one sparse product, linear in the number of edges, plus the MLP on every node, so a GIN layer runs at about the cost of a GCN layer with a two-layer MLP in place of one linear map.

Why one-layer perceptrons fall short

Many GNNs before GIN, GCN among them, transform each node with a single linear map followed by a nonlinearity, σ∘W\sigma \circ W, rather than an MLP. Lemma 7 shows that this can lose multisets that a sum of MLP outputs would keep:

∑x∈X1ReLU(Wx)=∑x∈X2ReLU(Wx)for every W\sum_{x \in X_1} \text{ReLU}(Wx) = \sum_{x \in X_2} \text{ReLU}(Wx) \quad \text{for every } W∑x∈X1ReLU(Wx)=∑x∈X2ReLU(Wx)for every W\begin{gathered} \sum_{x \in X_1} \text{ReLU}(Wx) = \sum_{x \in X_2} \text{ReLU}(Wx) \\ \text{for every } W \end{gathered}

with X1={1,1,1,1,1}X_1 = \{1, 1, 1, 1, 1\} and X2={2,3}X_2 = \{2, 3\}, two multisets of positive scalars with the same total, 5. Output coordinate ii computes ReLU(wix)\text{ReLU}(w_i x). For positive xx, the sign of wixw_i x is the sign of wiw_i, so the ReLU either zeroes every input or passes every input through linearly:

ReLU(wix)=x⋅ReLU(wi)for x>0\text{ReLU}(w_i x) = x \cdot \text{ReLU}(w_i) \quad \text{for } x > 0

Summed over a multiset, that is ReLU(wi)\text{ReLU}(w_i) times the multiset's total: 5 ReLU(wi)5 \,\text{ReLU}(w_i) for both. The layer degenerates into a plain sum of features, and the plain sum does not separate X1X_1 from X2X_2. Figure 4 plots one output unit.

Figure 4 · one ReLU unit summed over two multisets
weight ww = 0.80
b = 0 (off)
Drag the weight: with the bias off, the two stacked sums stay equal for every ww, including negative ones, where both are 0. Turn the bias on and move it: once the unit's bend at x=−b/wx = -b/w falls between the inputs, the sums differ (switched on at w=0.8w = 0.8, b=−1.5b = -1.5, they are 0 and 1.00).

The proof depends on the missing bias, and the paper says so: with a bias and enough output units, a one-layer perceptron might separate different multisets. Its argument for MLPs is broader. A one-layer perceptron is a generalized linear model and not a universal approximator of multiset functions, so even when it separates two neighborhoods it may place them in a way a simple classifier cannot use. The experiments test that claim, not the lemma: the code's one-layer variant is a linear layer with a bias, followed by batch normalization and ReLU.

What mean and max still capture

The paper titles its Section 5 "less powerful but still interesting GNNs". Mean keeps the proportions of each feature among the neighbors. When node features are rich and rarely repeat, two neighborhoods almost never have the same proportions without being the same multiset, and mean is as discriminative as sum. That describes node classification on citation graphs, where GCN does well: on Cora each paper carries a 1,433-dimensional bag-of-words vector, and its subject is predicted from the mix of subjects around it, which is a distribution.

Max keeps the set of distinct features and discards counts and proportions. That suits tasks that depend on which kinds of neighbor exist, such as picking out a skeleton of representative points; the paper cites PointNet, which learns this with a max over 3D points.

Degree features shrink the gap but do not close it. If each node has its own degree dd, a later layer can in principle multiply the neighbor mean by dd to recover the sum (max has no such fix). In the experiments, a mean-MLP model given one-hot degrees as features reaches 71.2% on REDDIT-BINARY and 41.3% on REDDIT-MULTI5K, up from chance but well below GIN's 92.4% and 57.5%.

Results on nine graph classification benchmarks

The experiments compare GIN-0 and GIN-ε with variants that swap one ingredient: mean or max instead of sum, and a one-layer perceptron instead of the MLP. "Mean, 1-layer" is the paper's stand-in for GCN and "max, 1-layer" for GraphSAGE. All use 4 message-passing layers and the readout (4.2), with a sum over nodes on the four bioinformatics datasets (molecules and proteins with categorical node labels) and a mean on the five social datasets, where nodes get one-hot degrees (IMDB, COLLAB) or a constant (REDDIT).

Training accuracy tests the theory directly, since a model that cannot separate two training graphs with different labels cannot fit both. With all hyperparameters fixed across datasets, GIN-0 and GIN-ε fit almost every training set almost perfectly; learning ϵ\epsilon gave no gain in fit. The mean, max and one-layer variants underfit on many datasets, in the order the theory predicts: MLPs above one-layer perceptrons, sum above mean and max. No GNN's training accuracy exceeded that of the WL subtree kernel run for 4 iterations, the ceiling Lemma 2 sets; on IMDB-BINARY none of the models fits the training set perfectly.

Figure 5 has the test accuracies from Table 1. Start on RDT-B, then switch datasets, and toggle the 2020 re-run.

Figure 5 · test accuracy, Table 1
Pick a dataset. Bars are mean test accuracy over 10 folds, whiskers one standard deviation, the dashed line chance. "Show 2020 re-run" adds GIN and a baseline that ignores edges, both re-evaluated by Errica et al. under a held-out protocol (not run on MUTAG or PTC).

The largest gaps are on the two REDDIT datasets, where structure is the only signal: GIN-0 scores 92.4% and 57.5% against 50.0% and 20.0% for both mean models and 81.0% and 52.5% for the WL kernel. On the other seven datasets the GNN variants mostly land within a standard deviation of each other; GIN-0 is the best GNN or statistically tied with it (a paired t-test at the 10% level) on all nine, and has the highest mean of all methods, alone or tied, on five. Two baselines are significantly better than every GNN: the WL kernel on NCI1 (86.0% against 82.7%) and PATCHY-SAN on MUTAG (92.6% against 89.4%). GIN-0 beats GIN-ε on 8 of 9 test sets and ties on the ninth; the paper attributes this to its simpler form, since both fit the training data equally well.

These are cross-validation numbers with the stopping epoch chosen to maximize the average accuracy over the same 10 folds, so they are optimistic. Errica et al. (2020) re-ran GIN with model selection inside each training fold: NCI1 drops to 80.0% and REDDIT-BINARY to 87.0%, and on PROTEINS GIN's 73.3% sits below a baseline that sums node features and never uses an edge (75.8%). On NCI1 and the REDDIT datasets the same baseline falls far behind (69.8% and 72.1%), so there the structure GIN can see does help.

Limitations

The WL bound holds for every model of the form (2.1), GIN included. GIN cannot separate a 6-cycle from two triangles, cannot count triangles in general, and fails on every pair the 1-dimensional WL test fails on. Morris et al. (2019) proved the same equivalence between GNNs and 1-WL in concurrent work and proposed k-dimensional GNNs, which pass messages between tuples of nodes to go beyond it at a higher cost; the paper's conclusion names going beyond neighborhood aggregation as future work.

The positive results are existence results under assumptions. Features must come from a countable set, and neighborhoods must have bounded size; the paper leaves real-valued features open. The injective ff exists and an MLP can approximate it, but nothing guarantees that gradient descent finds it, and the theory says nothing about which of the many functions that fit the training set will generalize.

The experiments do not test exactly the model the theorem describes. The social-network runs use a mean readout, which is not injective; the one-layer baselines have biases, which Lemma 7 excludes; and the reported accuracies are selected on the evaluation folds. The training-accuracy ordering supports the theory. The test-accuracy gaps outside the REDDIT datasets are mostly smaller than their standard deviations.

Provenance Verified against primary literatureHow we verify
Xu et al. (2019), Sec. 2, Eqs. (2.1) to (2.4)Message passing: a_v = AGGREGATE({h_u : u in N(v)}), h_v = COMBINE(h_v, a_v), h_v(0) = X_v; GraphSAGE max-pooling a_v = MAX({ReLU(W h_u)}); GCN written as h_v = ReLU(W MEAN{h_u : u in N(v) and v}); graph readout h_G = READOUT({h_v(K)}).
Sec. 4, Lemma 2 and Theorem 3; Appendices A and BAny GNN of the form (2.1) maps two graphs to different embeddings only if the WL test separates them. If f (over neighbor multisets), phi (combining with the node) and the readout are injective, the GNN separates every pair the WL test separates, given enough layers. The proof shows h_v(k) is an injective function of the WL color l_v(k) by induction.
Lemma 5 and Corollary 6; Appendices D and EFor a countable feature space and multisets of size below N, f(x) = N^(-Z(x)) makes sum f(x) unique per multiset, and any multiset function is phi(sum f(x)). (1 + eps) f(c) + sum f(x) is unique per (node, neighbor multiset) pair for irrational eps: eps (f(c) - f(c')) would be irrational while the other side of (E.1) is rational.
Sec. 4.1 to 4.2, Eqs. (4.1) and (4.2)GIN update h_v(k) = MLP(k)((1 + eps(k)) h_v(k-1) + sum of neighbors); one MLP models f(k+1) composed with phi(k); no MLP is needed before the first sum when inputs are one-hot. Readout concatenates READOUT over all depths k = 0..K, as in Jumping Knowledge networks.
Sec. 5, Lemma 7 and Corollaries 8 and 9; Appendices F to HLemma 7 counterexample X1 = {1,1,1,1,1}, X2 = {2,3} for a bias-free ReLU layer. Mean collides exactly for multisets with the same distribution, (S, m) and (S, k m), using f(x) = N^(-2Z(x)); max collides exactly for the same underlying set, using one-hot f into R^infinity.
Sec. 7 and Table 1Nine datasets, 10-fold cross-validation, the epoch with the best accuracy averaged over the 10 folds. 5 GNN layers including the input, 2-layer MLPs, BatchNorm on every hidden layer, Adam at 0.01 halved every 50 epochs; tuned: hidden 16 or 32 (bio) and 64 (social), batch 32 or 128, dropout 0 or 0.5. Sum readout on bioinformatics data, mean readout on social data. Max variants not run on REDDIT-B, REDDIT-M5K, COLLAB.
powerful-gnns/models/graphcnn.py (official code)num_layers counts the input (line 12), so 4 updates. GIN-0 adds self-loops to the sparse adjacency and sums (lines 97-104, 179); GIN-eps adds (1 + eps[layer]) * h with eps initialized to zeros (lines 32, 162). Every MLP is followed by BatchNorm and ReLU (164-167, 188-191). "average" pooling divides by the degree including the self-loop (180-183). Readout: one Linear per depth on sum- or average-pooled nodes, scores summed with dropout (220-227), equivalent to one Linear on the concatenation.
powerful-gnns/models/mlp.py, main.py, util.pyMLP with num_mlp_layers=2 is Linear, BatchNorm, ReLU, Linear; num_mlp_layers=1 is a single nn.Linear, which has a bias. Defaults: hidden 64, batch 32, 50 iterations per epoch, 350 epochs, Adam lr 0.01, StepLR(step 50, gamma 0.5), final dropout 0.5. Folds come from sklearn StratifiedKFold. At hidden 64 on MUTAG (7 input labels, 2 classes) the model has 31,192 parameters in use.
Zaheer et al. (2017), Deep Sets, Theorem 2 and its proofA function on sets from a countable universe is permutation invariant if and only if it can be written rho(sum phi(x)); the proof uses phi(x) = 4^(-c(x)). GIN's Lemma 5 extends this from sets to multisets of bounded size.
Errica et al. (2020), Sec. 6, Tables 3 and 4GIN re-evaluated with model selection inside each training fold: NCI1 80.0, PROTEINS 73.3, IMDB-B 71.2 and IMDB-M 48.5 and COLLAB 75.6 (degree features), REDDIT-B 87.0 and REDDIT-5K 53.8 (constant features). Structure-agnostic baseline (node features summed, then an MLP): NCI1 69.8, PROTEINS 75.8, IMDB-B 70.8, IMDB-M 49.1, COLLAB 70.2, REDDIT-B 72.1, REDDIT-5K 35.1.
Morris et al. (2019), Weisfeiler and Leman Go NeuralProved, concurrently with this paper, that GNNs have the same power as 1-WL to distinguish non-isomorphic graphs, and proposed k-dimensional GNNs to go beyond it.
This page, Figure 1 and the GCN comparisonThe WL runs (path vs star separated at round 1; the same-degree pair at round 2; hexagon vs two triangles and decalin vs bicyclopentyl never, color counts 2, 4, 4 from round 2 on) and the renormalized-GCN numbers on the 4-node star are our computations.
correctionSection 5.2 says of Figure 3(b) that "the sum aggregator still works because 1/2 (h_g + h_r) and 1/3 (h_g + h_r + h_r) are in general not equivalent". Those two expressions are means, and the sentence shows that mean separates that pair (in 3(b) only max fails, as the figure says); sum separates it too, with h_g + h_r against h_g + 2 h_r. Three claims are narrower than stated. (1) Table 1 labels the mean model "GCN", but Kipf and Welling's GCN weights each neighbor by 1/sqrt(d_u d_v) after adding self-loops, which is not a mean: on a 4-node star with identical features, one such step gives the center 1/4 + 3/sqrt(8) = 1.31 and each leaf 1/2 + 1/sqrt(8) = 0.85, so that GCN's output depends on degrees on unlabeled graphs, where a mean gives every node 1. It is still not injective and still bounded by the WL test. (2) Lemma 7 needs a layer without a bias; the code's 1-layer variant is nn.Linear (with a bias) followed by BatchNorm and ReLU, so the lemma does not cover the model in the experiments. (3) Theorem 3 needs an injective readout, and the social-network experiments use a mean readout. The reported accuracies are cross-validation accuracies with the epoch picked on the same folds; under a held-out protocol (Errica et al., 2020) GIN scores 2.7 to 5.4 points lower, and on PROTEINS (73.3) it falls below a baseline that ignores the edges (75.8).

Questions you might still have

?

Does GIN solve graph isomorphism?
No. GIN is exactly as strong as the 1-dimensional Weisfeiler-Lehman test and no stronger, and that test fails on many pairs: any two regular graphs with the same number of nodes and the same degree, such as a 6-cycle and two disjoint triangles, get identical colors in every round. No polynomial-time algorithm for graph isomorphism is known; the best known one, by Babai (2016), runs in quasipolynomial time.

?

If mean aggregation is weaker, why does GCN work so well on citation networks?
Because mean only loses information when features repeat. On Cora each node carries a 1,433-dimensional bag-of-words vector, two neighbors almost never have identical vectors, and the label of a paper depends on the mix of topics around it, which is what a mean reports. Corollary 8 says mean collides only on multisets with the same proportions, such as {a, b} and {a, a, b, b}; with rich, rarely repeated features those cases are rare. The site's GCN explainer covers that model.

?

Should I use GIN-0 or GIN-ε?
The paper found no difference in training fit and a small, consistent test advantage for GIN-0: higher on 8 of 9 datasets and tied on NCI1, by 0.1 to 0.9 points, well inside the fold-to-fold standard deviations of 1.5 to 8.2 points. GIN-ε is strictly more expressive in theory: footnote 2 says some (somewhat contrived) graphs are separated by GIN-ε and not by GIN-0, such as a node of type a with one neighbor of type b against the reverse, which GIN-0 merges at the next layer.

?

Does a more expressive GNN generalize better?
Not necessarily. The theorems are about which graphs a model can map to different vectors, which bounds how well it can fit training data; they say nothing about test accuracy. The paper's training curves match the theory (sum and MLPs fit best), but on test sets the variants are often within a standard deviation of each other, and a 2020 re-evaluation found a model that ignores edges beating GIN on PROTEINS.

?

How many layers does a GIN need?
Enough rounds for WL colors to stop splitting. Colors only ever split, since each new color includes the old one, and a graph with n nodes can hold at most n colors, so refinement stabilizes within n - 1 rounds; in practice it stabilizes much sooner (round 2 for decalin). The paper uses 4 message-passing layers on graphs averaging 13 to 509 nodes, and concatenates the readout of every depth so that information from early layers stays available to the classifier.

?

What changes if node features are real numbers instead of categories?
The proofs assume features come from a countable set, which covers one-hot labels and degrees. With real-valued features, a sum of learned functions can no longer be guaranteed to be unique per multiset by the same digit argument, and the paper explicitly leaves the uncountable case to future work.

?

Does GIN use edge features, such as bond types in a molecule?
Not in the paper. Equation (4.1) sums neighbor vectors with weight 1 for every edge, and the official code builds its adjacency matrix from ones, so a single and a double bond look the same. Node labels carry all the input information in the experiments. Adding edge features means changing the message each neighbor sends, and the injectivity argument then has to cover (neighbor, edge) pairs instead of neighbors.

?

Is max-pooling ever the right aggregator?
When the task depends on which kinds of neighbor are present, not how many. By Corollary 9, the max over a neighborhood depends only on its underlying set. The paper cites PointNet, where a max over points learns to pick out a skeleton of a 3D point cloud and is reported to be robust to noise and outliers.

Footnotes & further reading

  1. The paper: Xu, Hu, Leskovec & Jegelka, How Powerful are Graph Neural Networks? (ICLR 2019; arXiv v3, February 2019). Code: weihua916/powerful-gnns.
  2. The WL subtree kernel: Shervashidze, Schweitzer, van Leeuwen, Mehlhorn & Borgwardt, Weisfeiler-Lehman Graph Kernels (JMLR 2011). Graphs that defeat WL tests of every fixed dimension: Cai, Fürer & Immerman, An optimal lower bound on the number of variables for graph identification (Combinatorica, 1992). The quasipolynomial isomorphism algorithm: Babai, Graph Isomorphism in Quasipolynomial Time (2016).
  3. Sum decompositions for sets: Zaheer, Kottur, Ravanbakhsh, Poczos, Salakhutdinov & Smola, Deep Sets (NeurIPS 2017). Per-depth readout: Xu, Li, Tian, Sonobe, Kawarabayashi & Jegelka, Representation Learning on Graphs with Jumping Knowledge Networks (ICML 2018).
  4. The aggregators GIN is compared against: Kipf & Welling's GCN, Hamilton, Ying & Leskovec's GraphSAGE and Veličković et al.'s GAT, each explained on this site (GCN, GraphSAGE, GAT).
  5. The concurrent 1-WL result: Morris, Ritzert, Fey, Hamilton, Lenssen, Rattan & Grohe, Weisfeiler and Leman Go Neural: Higher-order Graph Neural Networks (AAAI 2019). The re-evaluation: Errica, Podda, Bacciu & Micheli, A Fair Comparison of Graph Neural Networks for Graph Classification (ICLR 2020).