Graph Attention Networks (GAT)
A GNN that learns how much attention to pay to each neighbour.
The idea
Instead of averaging neighbours equally, GAT scores each (node, neighbour) pair with a small learnable function, normalises the scores with a softmax across the neighbours and takes the weighted sum. Important neighbours count more, and several attention heads can be used in parallel.
αᵢⱼ = softmaxⱼ(LeakyReLU(aᵀ[Whᵢ ‖ Whⱼ]))
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- node feature
- messages to centre node
Each node holds a number (darker = bigger). In a graph network every node updates itself using only the nodes it is linked to.
- layer:
- 0
- spread:
- 0.937
Add more layers and notice the numbers drift together: too many rounds blur node identities.
Step by step
- 1Transform every node's features with a shared weight matrix.
- 2Score each edge with an attention function.
- 3Softmax the scores over each node's neighbours.
- 4Aggregate neighbour features weighted by those scores.
Where it is used
Graphs where neighbours differ in importance.
Watch out for
Costlier than GCN and can overfit on small graphs.