DL0191 GCN, GraphSAGE, and GAT

How do Graph Convolutional Networks (GCN), GraphSAGE, and Graph Attention Networks (GAT) differ in their neighborhood aggregation strategies, and what are the trade-offs in transductive versus inductive settings?

Answer

All three layers do the same thing at a high level: build a new vector for node i as a weighted combination of its neighbors’ vectors, then apply a linear map and a nonlinearity. The real difference is where the mixing coefficient comes from and how the neighborhood is enumerated. GCN fixes the coefficient from the graph alone as symmetric degree normalization 1/\sqrt{\tilde{d}_i \tilde{d}_j}, applied to the full neighborhood in one sparse matrix product over the entire graph. GraphSAGE replaces the full neighborhood with a fixed-size random sample and a permutation-invariant aggregator (mean, max-pool, or LSTM), and keeps the node’s own vector in a separate concatenated slot instead of averaging it away. GAT makes the coefficient content-dependent: a small shared scoring vector reads both endpoint features, a softmax over each node’s neighborhood turns those scores into weights \alpha_{ij}, and several attention heads are run in parallel. Transductive versus inductive is then mostly a property of the training procedure and of what the coefficients depend on, not of the layer equation itself.

(1) GCN Weights Are Structural And Frozen: c_{ij} depends only on the two degrees, so a high-degree hub is deliberately down-weighted and no coefficient is ever learned. This is a strong, cheap prior when features are weak and the graph is homophilous.
(2) GraphSAGE Weights Are Uniform Over A Sample: the mean aggregator gives every sampled neighbor 1/|S(i)|, and the sample size is the knob that bounds compute rather than the node’s true degree.
(3) Self Vector Handling Differs: GCN and GAT fold the node into the same sum through a self-loop, while GraphSAGE concatenates it and gives it its own block of the weight matrix, which preserves the node’s own signal at depth.
(4) GAT Weights Are Learned From Features: \alpha_{ij} can vary across edges of identical degree, which is what lets the layer ignore a noisy neighbor. The price is K|E| stored coefficients and gradients flowing through the attention scores.
(5) Transductive Is A Training Choice, Not A Law: the published GCN is trained full-batch on a single normalized adjacency, so a new node changes degrees and the normalization; GraphSAGE was designed minibatch-first so the same weights run on an unseen node by sampling its fan-out.
(6) Depth Costs Differently: full-neighborhood expansion grows as roughly \bar{d}^{\,L} per target node, while sampling caps it at \prod_l S_l at the cost of estimator variance.

Three side-by-side panels showing the same target node with four neighbors A, B, C, D. In the GCN panel the incoming arrow thickness follows fixed degree-based coefficients 0.32, 0.26, 0.18 and 0.15 with a self-loop coefficient 0.20. In the GraphSAGE panel only A and C are sampled with equal weight 0.50, B and D are drawn as dashed gray unsampled nodes, and the target keeps its own vector through concatenation. In the GAT panel the coefficients are learned attention values 0.09, 0.46, 0.11, 0.19 with self attention 0.15, so arrow thickness no longer tracks degree.

Figure 1: One neighborhood, three weighting rules. GCN reads its coefficients off the degrees, so the sparsest neighbor A gets the largest share and the hub D the smallest. GraphSAGE throws away two neighbors and splits the mass uniformly over what survives, keeping the self vector in a separate concatenated slot. GAT lets features decide, so neighbor B dominates with \alpha = 0.46 despite having a middling degree.

Mathematical Formulation:
h_i' = \sigma\big(\textstyle\sum_{j \in \tilde{N}(i)} c_{ij} W h_j\big)
c_{ij} = 1 / \sqrt{\tilde{d}_i \tilde{d}_j}
a_i = \mathrm{AGG}(\{h_j : j \in S(i)\})
h_i' = \sigma(W \, [\, h_i \,\|\, a_i \,])
e_{ij} = \mathrm{LeakyReLU}(a^{\top}[W h_i \,\|\, W h_j])
\alpha_{ij} = \mathrm{softmax}_j(e_{ij})
h_i' = \sigma\big(\textstyle\sum_{j \in \tilde{N}(i)} \alpha_{ij} W h_j\big)

Where:

  • h_i \in \mathbb{R}^{d} is the incoming representation of node i and h_i' the layer output; \sigma is the elementwise nonlinearity and W the shared linear map.
  • \tilde{N}(i) is the neighborhood including the self-loop, and \tilde{d}_i is the corresponding degree, so c_{ij} is the fixed GCN coefficient that never changes during training.
  • S(i) \subseteq N(i) is the sampled fan-out of fixed size S_l at layer l, and \mathrm{AGG} is a permutation-invariant reducer (mean, elementwise max over an MLP, or LSTM over a shuffled order).
  • \| is concatenation, so the GraphSAGE weight matrix has shape d' \times 2d and the node’s own features get an independent parameter block.
  • a \in \mathbb{R}^{2d'} is the shared attention vector and e_{ij} the raw score; the softmax is taken over j \in \tilde{N}(i) so that \sum_j \alpha_{ij} = 1 per node.
  • GAT runs K heads whose outputs are concatenated in hidden layers and averaged in the output layer, multiplying both parameter count and stored coefficients by K.

The cost picture follows directly. A full-batch GCN layer is O(|E| d + |V| d^2) and needs the whole feature matrix plus every layer’s activations resident, which is why it stops fitting long before the graph itself does. GAT adds O(K |E|) scores and their gradients on top of the same sparse pattern, so its memory is edge-bound rather than node-bound. GraphSAGE instead bounds a minibatch: with batch size B and fan-outs (S_1, \ldots, S_L), the computation graph holds a number of node instances that is completely independent of |V|. That is the property that makes web-scale graph learning practical, and it is the mechanism behind Pinterest’s PinSage, which trains on a graph of billions of nodes by expanding only short sampled neighborhoods per target.

Minibatch Fan-Out Budget:
N_{mb} = B \prod_{l=1}^{L} S_l
25 \times 10 = 250
N_{mb} = 512 \times 250 = 128000

Log-scale line chart of node instances in the computation graph for a single target node versus GNN depth from 1 to 4 layers. Full-neighborhood expansion at average degree 100 rises from 100 to about 101 million, full-neighborhood expansion at average degree 20 rises from 20 to about 168 thousand, and sampled fan-out 25 then 10 per layer rises only from 25 to about 28 thousand. A dashed horizontal line marks a graph of 2.4 million nodes, which the average-degree-100 curve crosses between three and four layers.

Figure 2: Depth is what makes full-neighborhood aggregation intractable. On a graph with average degree 100, a 3-hop receptive field already touches about a million node instances per target and a 4-hop field exceeds the graph size, meaning most of the graph is re-visited for a single prediction. A fixed fan-out of 25 then 10 keeps the same depth at roughly 2,800 instances, trading exactness for a cost that no longer depends on |V|.

PropertyGCNGraphSAGEGAT
Neighbor weightFixed 1 / sqrt(d_i d_j)Uniform 1 / |S(i)|, or max-pool / LSTM reducerLearned alpha_ij per head, softmax over the neighborhood
Weight depends onGraph structure onlySample size onlyEndpoint features, so it changes as the model trains
Self representationSelf-loop term inside the same sumConcatenated, own block of the weight matrixSelf-loop with its own attention coefficient
Published training regimeFull-batch over one normalized adjacencyMinibatch with fixed per-layer fan-out samplingFull-batch on citation graphs, sampled variants for large graphs
Unseen node at inferenceDegrees and normalization must be recomputed; the transductive recipe assumes the test nodes were present during trainingDesigned for it: sample the fan-out and run one forward passWorks if the new node has features, since attention is edge-local
Per-layer costO(|E| d + |V| d^2), memory scales with the whole graphO(B x prod S_l x d) per batch, independent of |V|K x O(|E| d), plus K|E| stored coefficients and their gradients
Dominant failure modeOver-smoothing beyond two or three layers; hubs are dampened by constructionSampling variance and unstable embeddings; fan-out explodes at three or more layersEdge-bound memory; static attention ranking, which GATv2 fixes

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *