Deep Learning Graph Neural Networks
Many real-world datasets look like webs of connections instead of grids or sequences. Friends link to friends, atoms bond to atoms, and roads join at intersections. A Graph Neural Network, or GNN, learns directly from this connected structure and makes predictions about nodes, links, or whole networks.
What Is a Graph
A graph contains nodes and edges. Nodes are the items, and edges are the connections between them.
Social network graph:
Ana ---- Ben
| |
Cara ---- Dev ---- Eli
Nodes: Ana, Ben, Cara, Dev, Eli
Edges: the lines between people
Why Regular Networks Struggle
Images have fixed grids, and sentences have a fixed order. Graphs have neither. One person may have 3 friends and another may have 3,000, and no node sits at a fixed position. A GNN handles any size and shape.
The Core Idea: Message Passing
Each node holds a list of numbers that describes it. In every round, each node collects the lists from its neighbours, combines them, and updates its own list. Picture a rumor spreading through a neighbourhood. After a few rounds, each person knows what their friends and friends of friends know.
Round 1: each node hears from direct neighbours Round 2: each node hears about neighbours of neighbours Round 3: information travels three steps away Node Dev updates: new Dev = combine( Dev, Ben, Cara, Eli )
One Layer in Detail
1. Gather: collect neighbour feature lists 2. Aggregate: average or add them into one list 3. Update: mix the result with the node's own list 4. Activate: apply a function such as ReLU
Stacking two or three layers lets each node see a wider neighbourhood. Very deep GNNs blur all nodes into similar values, so practitioners keep them shallow.
Types of Graph Tasks
Node Prediction
The model labels each node. An example is spotting suspicious accounts in a payment network.
Link Prediction
The model predicts whether two nodes should connect. Friend suggestions and product recommendations use this task.
Graph Prediction
The model labels an entire graph. Chemists treat a molecule as a graph of atoms and bonds and predict properties such as solubility.
Molecule graph: H
|
H -- C -- O -- H
|
H
Prediction for the whole graph: "dissolves in water"
Popular GNN Designs
| Model | Key Idea |
|---|---|
| Graph Convolutional Network (GCN) | Averages neighbour features, like a convolution on a graph |
| GraphSAGE | Samples a few neighbours, which scales to huge graphs |
| Graph Attention Network (GAT) | Learns which neighbours deserve more weight |
Real-World Applications
- Recommending movies, products, and music
- Predicting travel times on road networks
- Discovering candidate drug molecules
- Detecting fraud rings in financial data
- Understanding knowledge graphs for search engines
Practical Tips
- Start with a two-layer GCN as a baseline
- Normalize node features before training
- Split data carefully so test nodes do not leak into training links
- Use libraries such as PyTorch Geometric or Deep Graph Library
Key Terms
- Node - an item in a graph
- Edge - a connection between two nodes
- Message passing - nodes exchanging information with neighbours
- Aggregation - combining neighbour information into one list
- Link prediction - guessing which connections should exist
