↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

Learned weights on edges

A GCN weighs neighbour of node by , a number fixed by the degrees before training starts. The graph attention network (GAT) of Veličković et al. (2018) learns the weights instead. For every edge , self-loop included, it scores the pair from the two nodes' vectors after a shared weight matrix , and normalizes the scores over 's neighbours with a softmax:

and the node's new vector is . As in a transformer, several heads do this in parallel with their own and , and their outputs are concatenated. The model here follows the paper's Cora setup: 8 heads of 8 features with ELU, then one head producing the 7 topic scores, dropout 0.6 on each layer's input and on the attention weights, 92,373 weights in all.

Unlike transformer attention, GAT only attends along the graph's edges: a paper can weigh the papers it cites or is cited by, nothing else. The Graph Transformer tab drops that restriction.

Attention next to GCN's weights

The Weights on the edges panel draws the weights flowing into one paper twice: GCN's fixed weights, rescaled to shares that sum to 1 so they compare with , and the selected head's learned . The table gives every incoming edge in all 9 heads, coloured by the weight relative to an even share on one logarithmic scale.

For paper 2472 the contrast is the main result of this page. GCN's degree weights range from 0.63 to 1.47 times an even share: the paper with one citation gets far more than the one with ten. After 200 epochs the 8 first-layer heads stay between 0.89 and 1.29 times even, and the output head between 0.99 and 1.003. The model learns attention, but on Cora it learns to spread it almost evenly.

Entropy over training

To see this over the whole graph, the Distance from uniform panel averages over all 2,708 papers the gap between the largest possible entropy of node 's attention and its actual entropy . At initialization the gap is about nats in every head: small random weights give nearly equal scores. It grows during training, but after epoch 200 it is between and nats in the first-layer heads and in the output head, which rose to around epoch 74 and then fell back. GCN's fixed weights, made into shares, sit nats from even: 18 times farther than the farthest head after the last epoch, and 3.6 times farther than the output head at its peak.

The lower chart asks whether the heads at least favour neighbours of the paper's own topic, which is what would help classification. The ratio of the mean weight on same-topic neighbours to the mean weight on other-topic neighbours ends between 0.999 and 1.007: a lean of under one per cent, learned from the words alone, since labels never enter the attention.

This matches what others found. Knyazev et al. (2019) and Kim and Oh (2021) observed that GAT's attention on citation graphs is close to uniform, and Shchur et al. (2018) found that across random splits GAT and GCN reach similar accuracy on these datasets. Here both reach 82.1 % test accuracy on the standard split.

Static attention and disagreeing heads

The score is a sum of a sender term and a receiver term, passed through a monotonic LeakyReLU. For a fixed receiver the receiver term is the same for every neighbour, so each head ranks every node's neighbours by the same sender score. Brody et al. (2022) called this static attention: one global ranking of nodes per head, whoever is asking. Their GATv2 applies the nonlinearity before the dot product with , so the ranking can depend on the receiver. Hovering a cell of the table shows the sender score behind it.

Heads can still differ. The Where heads disagree panel measures, per paper, the mean total-variation distance between the 8 first-layer heads' distributions: 0 when they agree, 1 when two heads put their weight on different neighbours. The median paper scores 0.016 and the largest 0.076, for paper 1430, a Neural networks paper with two neighbours: heads 1 and 8 give its neighbour 1718 about 0.48 of its attention, where an even share is 0.33 and GCN would give it 0.26.

How it was recorded

The run trains on the 140 labelled papers of the Planetoid split for 200 full-graph epochs with Adam (learning rate 0.005, weight decay ) on one CPU thread, with dropout off whenever attention is measured. After the last epoch: 99.3 % train, 79.6 % validation and 82.1 % test accuracy. The layers are written in plain PyTorch (the </> chips) and checked against PyTorch Geometric's GATConv, including the attention weights it returns; the check also retrains the run from its seed and gets every recorded loss and the final weights.

Papers

  1. Graph Attention Networks Petar Veličković et al. · ICLR 2018 The GAT layer and the Cora setup this page trains.
  2. How Attentive are Graph Attention Networks? Shaked Brody, Uri Alon, Eran Yahav · ICLR 2022 Static attention: GAT ranks neighbours by the sender alone; GATv2 fixes it.
  3. How to Find Your Friendly Neighborhood: Graph Attention Design with Self-Supervision Dongkwan Kim, Alice Oh · ICLR 2021 Measures how far learned graph attention is from uniform and when it helps.
  4. Understanding Attention and Generalization in Graph Neural Networks Boris Knyazev, Graham W. Taylor, Mohamed R. Amer · NeurIPS 2019 When attention in GNNs learns something useful, and when it stays close to uniform.
  5. Pitfalls of Graph Neural Network Evaluation Oleksandr Shchur et al. · arXiv 2018 GCN and GAT compared fairly across splits of Cora and other graphs.
  6. Semi-Supervised Classification with Graph Convolutional Networks Thomas N. Kipf, Max Welling · ICLR 2017 GCN, whose fixed degree weights this page sets beside the learned ones.

See also