Graph Attention Networks (GAT)

GAT banner Kaggle

  • Paper: Graph Attention Networks
  • Authors: Petar Veličković, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, Yoshua Bengio
  • Lab, year: University of Cambridge, Centre de Visió per Computador (UAB) and Montréal Institute for Learning Algorithms, 2017 (ICLR 2018)
  • Video: YouTube Short coming on 15 Dec 2026 on Backprop Daily

Summary

The paper introduces graph attention networks (GATs). Each node updates its features by taking a weighted average of its neighbours’ features, and the weights are learned by an attention mechanism instead of being fixed by the graph structure. A two-layer GAT reached 83.0% accuracy on Cora, 72.5% on Citeseer and 79.0% on Pubmed, and a micro-F1 of 0.973 on the PPI protein graphs, where the test graphs are not seen in training (Section 3.4, Tables 2 and 3).

What Problem Does It Solve

Graph convolutional networks such as GCN give each neighbour a weight that depends only on node degrees. GAT lets the model give different importance to different nodes in the same neighbourhood (Section 2.2). Because the attention is applied to each edge with shared weights, it also does not need the whole graph up front, so it works on graphs that were never seen during training (Section 2.2).

Core Idea

For each edge from j to i, the model computes a score e_ij = LeakyReLU(aᵀ[W h_i ‖ W h_j]), where W is a shared linear map and a is a learned vector; LeakyReLU has negative slope 0.2 (Section 2.1, Eqs. 1–3). The scores are normalised with a softmax over the neighbours of i, including i itself (“masked attention”), and the new features are the weighted sum of the neighbours’ W h_j. Several independent attention heads are run in parallel; hidden layers concatenate them and the output layer averages them (Section 2.1, Eqs. 4–6).

Key Method Details

  • Transductive model: layer 1 has K = 8 heads with F′ = 8 features each (64 in total) and ELU; layer 2 has one head with C outputs and softmax (Section 3.3).
  • Regularisation: L2 with λ = 0.0005, and dropout p = 0.6 on both layers’ inputs and on the attention coefficients (Section 3.3).
  • Training: Glorot initialisation, Adam with learning rate 0.005 (0.01 for Pubmed), early stopping with patience 100 (Section 3.3).
  • Cost: one head costs O(|V|FF′ + |E|F′), on par with GCN, with no eigendecompositions (Section 2.2).
  • Attention helps on PPI: the same architecture with constant attention (Const-GAT) scored 0.934 against 0.973 for GAT (Section 3.4, Table 3).

Simplifications in This Notebook

  • Graph: Zachary’s karate club (34 nodes, 78 unweighted edges, 2 factions) with one-hot node ids as features, instead of Cora, Citeseer, Pubmed or PPI.
  • Implementation: NumPy with a hand-written backward pass (checked against numerical gradients) and dense 34 × 34 attention matrices.
  • Training: 6 labelled nodes (3 per faction), Adam with learning rate 0.005, L2 0.0005 on the weights, a fixed 150 epochs, no dropout and no early stopping.
  • Baseline: a 2-layer GCN with 16 hidden units trained with the same settings.

What the Notebook Result Shows

  • The gradients are right: analytic and numerical gradients agree to 2.35e-10.
  • GAT works on this graph: with seed 42 it reaches 0.9286 accuracy on the 28 unlabelled nodes (0.9412 on all 34); nodes 8 and 30 are wrong.
  • Slightly better than GCN here: over seeds 0 to 4, unlabelled accuracy was 0.9214 ± 0.0350 for GAT and 0.8571 ± 0.0000 for GCN. That is about 2 of 28 nodes on one small graph, and the GAT has more hidden features (64 vs 16).
  • The earlier version was wrong to claim an advantage: its GAT scored 0.9412 and its GCN 0.9706 on all nodes, with different training for each.

Influence

The authors released a TensorFlow implementation (PetarV-/GAT) and a project page. PyTorch Geometric’s GATConv layer implements the paper’s attention layer. OpenAlex lists about 24,900 citations (24,928 when checked on 3 December 2026).


Resources

File Description
README.md This overview — a 5-minute read covering the paper’s summary, core idea, key method details, influence, and a plain-English explanation of the problem it solves
solution.ipynb From-scratch NumPy two-layer GAT on the karate club graph, with a gradient check, attention plots and a 5-seed comparison with a GCN trained the same way
CODE_ARCHITECTURE.md Section-by-section breakdown of the notebook — what each cell does, data flow, tensor shapes, and key design decisions
TALK.md Press coverage, Q&A (answers from the paper), citations, and common misconceptions about the paper

Table of contents