Graph Neural Networks — Complete Guide
GNNs learn from graph-structured data — social networks, molecules, knowledge graphs.
Why GNNs?
Traditional ML: Assumes independent data points
Graph data: Data points are CONNECTED
Examples:
├─ Social networks: Users connected by friendships
├─ Molecules: Atoms connected by bonds
├─ Citations: Papers connected by references
└─ Knowledge graphs: Entities connected by relations
Message Passing
GNN Layer:
For each node:
1. Collect messages from neighbors
2. Aggregate messages
3. Update node representation
h_v^(t+1) = UPDATE(h_v^(t), AGGREGATE({h_u^(t) : u ∈ N(v)}))
Where:
h_v = node v's representation
N(v) = neighbors of v
GNN Variants
GCN (Graph Convolutional Network):
├─ Spectral-based
├─ Averaging neighbor features
└─ Simple and effective
GraphSAGE:
├─ Sample neighbors (scalable)
├─ Multiple aggregation functions
└─ Inductive (works on new nodes)
GAT (Graph Attention Network):
├─ Attention over neighbors
├─ Learn which neighbors matter
└─ More expressive than GCN
Key Takeaways
- GNNs learn from graph-structured data
- Message passing aggregates neighbor information
- GCN is the simplest GNN
- GraphSAGE scales to large graphs
- GAT learns attention over neighbors
- Applications: molecular property prediction, social networks, recommendations
- Over-smoothing is a challenge for deep GNNs
- Graph Transformers combine GNNs with attention