A Simple Neural Network Module for Relational Reasoning
Relation Networks for learning to reason about object relationships
Updated
Contents
A Simple Neural Network Module for Relational Reasoning introduced Relation Networks (RNs) — a small, plug-in architecture built on one idea: to reason about relationships, explicitly look at every pair of objects. Despite its simplicity, it beat humans on a visual reasoning benchmark.
No heavy prerequisites here — just basic neural network concepts (MLPs and CNNs). This is one of the most accessible “reasoning” papers in deep learning.
Why Students Should Care
- It is a clean case study in inductive bias: bake the shape of the problem (pairwise relations) into the architecture, and a simple model suddenly beats much bigger generic ones.
- It achieved superhuman accuracy on CLEVR, a benchmark specifically designed to require reasoning, not pattern matching.
- Pairwise-interaction thinking is everywhere: self-attention in Transformers, edges in graph neural networks, and memory interactions in Relational RNNs.
The Problem
Standard neural networks struggle with questions that hinge on relationships:
- “Is object A larger than object B?”
- “What is between the red and blue objects?”
- “Are there more circles than squares?”
A CNN is great at detecting what is in an image, but nothing in its architecture compares one detected thing to another. These questions require comparing pairs of entities — and standard architectures give the model no direct way to do that.
Relation Networks: Just Compare Every Pair
The key insight: don’t hope the network discovers pairwise comparison — build it in. Run a small network over all pairs of objects, then sum the results:
where:
- are object representations
- is a small MLP that processes each pair — the “relation” function
- is another MLP that turns the summed relations into an answer
In words: score every pair, add up the scores, read out the answer. That is the entire architecture.
Interactive Demo
Explore relational reasoning on simple visual scenes:
Relational Reasoning
Why Pairs Matter
For objects, the RN considers all pairs. This:
- Captures relations regardless of object order (summing is order-independent)
- Scales to variable numbers of objects (the same is reused for every pair)
- Avoids hardcoding which relations matter — learns that from data
Architecture Details
For visual question answering, “objects” don’t need to be detected explicitly:
- CNN extracts a feature map from the image
- Objects = the spatial locations (cells) of that feature map
- The question embedding is concatenated to each pair
- g network (MLP) processes each triple
- Sum over all pairs
- f network (MLP) produces the answer
Step 3 is worth noticing: conditioning on the question lets the same pair of objects be related differently depending on what is being asked.
Results on CLEVR
CLEVR is a visual reasoning benchmark with questions like “What size is the cylinder that is left of the brown metal thing?” — designed so that shortcut statistics don’t work.
| Model | Accuracy |
|---|---|
| CNN + LSTM | 42.7% |
| CNN + LSTM + Attention | 68.5% |
| Relation Network | 95.5% |
| Human | 92.6% |
RNs achieved superhuman performance — on a task where generic architectures barely beat chance-plus-heuristics.
Key Properties
Permutation invariant: summing over pairs is order-independent, so shuffling the objects changes nothing
Relation-centric: pairwise interactions are modeled explicitly, not left for the network to discover
Data efficient: the strong inductive bias means less data is needed to learn relational tasks
Beyond Vision
RNs also improved:
- Text QA (bAbI dataset)
- Physical reasoning (predicting dynamics)
- Graph problems (when combined with GNNs)
Connection to Attention
Self-attention can be viewed as a form of relation network:
Both aggregate pairwise interactions; attention additionally learns weights for each pair instead of summing them uniformly.
Common Confusion
- Relation Networks vs. Relational RNNs: RNs compare all object pairs within a single input; Relational RNNs let memory slots interact over time. Related idea, different setting.
- Relation Networks vs. graph neural networks: an RN is like one round of message passing on a fully connected graph — every object talks to every object, no graph structure required.
- “Objects” are not detections: in the vision setup, objects are just feature-map cells. No object detector is involved.
- The cost is real: comparing all pairs is quadratic in the number of objects — the same scaling cost that self-attention pays over sequence length.
Where To Go Next
- Read Relational RNNs for pairwise interaction applied to recurrent memory.
- Read Neural Message Passing for the general graph-structured version of this idea.
- Read Attention Is All You Need for learned, weighted pairwise interaction at scale.
- Read CS231n for the CNN background used in the vision pipeline here.
Key Paper
- A Simple Neural Network Module for Relational Reasoning — Santoro et al. (2017)
https://arxiv.org/abs/1706.01427