Graph Neural Networks Quick Reference
Quick reference for GNN formulas, architectures, and code.
Key Formulas
Message Passing
$$h_v^{(l+1)} = \text{UPDATE}(h_v^{(l)}, \text{AGGREGATE}({h_u^{(l)} : u \in \mathcal{N}(v)}))$$
GCN
$$H^{(l+1)} = \sigma(\tilde{D}^{-1/2} \tilde{A} \tilde{D}^{-1/2} H^{(l)} W^{(l)}),\quad \tilde{A}=A+I$$
GAT Attention
$$\alpha_{vu} = \text{softmax}(\text{LeakyReLU}(a^T [W h_v | W h_u]))$$
Architectures Comparison
| Architecture | Aggregation | Attention | Inductive |
|---|---|---|---|
| GCN | Mean | No | No |
| GAT | Weighted mean | Yes | No |
| GraphSAGE | Sample + Aggregate | No | Yes |
| GIN | Sum | No | Yes |
Libraries
- PyTorch Geometric:
from torch_geometric.nn import GCNConv - DGL:
import dgl.nn as dglnn - Spektral: Keras/TensorFlow