A graph attention network (GAT) is a graph neural network for classifying nodes by combining each node’s features with information from its neighbors. Unlike a graph convolutional network (GCN), which averages neighbor features equally, a GAT learns how much weight to give each neighbor. This can distinguish nodes with the same neighbors but different connection patterns. section 9.4.1 section 9.5
Figure 9.22 Comparison of a GAT model layer with a GCN model layer, showing how the GAT model uses the attention mechanism to derive different weights/importances for different neighbors of a given node.
The layer comparison shows the key shift: replace equal neighbor averaging with learned, neighbor-specific importance weights before aggregation. section 9.4.1
A GAT layer uses a shared trainable attention vector to calculate an attention coefficient for every node–neighbor pair. Those coefficients become custom averaging weights, so the model can emphasize neighbors and feature dimensions that are more useful for deciding a node’s class. section 9.4.1
A practical illicit-transaction workflow is:
- Start with graph node features and an edge index representing transaction neighborhoods; use an untrained model’s scattered predictions as a baseline. section 9.4 section 9.4.3
- Replace GCNConv layers with PyG GATConv layers, then select hidden channels and the number of attention heads. section 9.4.2
- Train with the existing graph-model loop, monitor loss, validation accuracy, and F1 score, then evaluate on an unseen test set. section 9.4.4
- Visualize test predictions to check whether illicit and licit transactions separate in two dimensions. section 9.4.5
Multi-head GAT for Bitcoin transactions
A two-layer PyG model accepts 165 input features per transaction. Its first GATConv layer uses 4 heads that each produce 8 features; concatenation produces 32 features for a second, single-head layer that outputs licit and illicit classes. Multiple heads perform independent neighborhood aggregations, giving the next layer several learned views of the graph. section 9.4.2
On the Elliptic Bitcoin dataset, attention-weighted aggregation improved reported test performance over the earlier MLP and GCN baselines: the GAT reached 95.74% accuracy and a 95.46% F1 score in one evaluation. A trained prediction plot showed clearer separation of illicit from licit transactions. These results are dataset-specific, so retain held-out evaluation and learning-curve checks when adapting the model. section 9.4.4 section 9.4.5
GATs aggregate all neighbors, which can become difficult for nodes with very large neighborhoods. GraphSAGE is a related graph neural network approach that instead samples a subset of neighbors during training for large graphs. section 9.4.5 section 9.5



