Paper commentary
Spatial Transformer Networks
Spatial transformers let CNNs learn invariance to large input warps
- Problem Max-pooling gives CNNs only small, fixed shift tolerance, so features still move under large input transformations. Its rule is fixed in advance and cannot adapt to each image.
- Method The Spatial Transformer is a learnable module that predicts a spatial warp from each input feature map and applies it. Unlike pooling, it acts on the whole map and trains end to end with back-propagation.
- Results On SVHN with 64 by 64 crops, ST-CNN Multi scored 3.6% sequence error, compared to 3.9% for the previous best.
Why max-pooling falls short
Max-pooling gives a CNN some tolerance to small shifts of a feature, but its spatial support is small, for example 2 by 2 pixels. That tolerance only builds up across a deep stack of pooling and convolution layers. Intermediate feature maps still aren't invariant to large transformations of the input, as earlier analyses found. The root cause is a pooling rule that is limited and fixed in advance, so it can't adapt to how each image varies.
The authors want a module that chooses the spatial warp for each sample, instead of relying on a fixed local rule. Unlike pooling, the module's transformation acts on the whole feature map rather than on a fixed local region. That lets a network select the relevant regions and also bring them to a canonical pose.
A learned warp inside the network
The key idea is to let the network predict a spatial warp from each input and apply that warp to the input's feature map. The module is self-contained, so it can sit at any depth of a CNN and in any number. It is trained with standard back-propagation, so the whole model trains end to end.
The three parts run in order: a localisation network, a grid generator and a sampler. The localisation network reads the input feature map U with width W, height H and C channels, and outputs the transformation parameters \(\theta\). The grid generator warps a regular output grid G through T_\(\theta\), which gives the source points where the input is read.
The sampler reads the input at those points and writes the output feature map V.
In the affine case, each target point maps to a source point through a 2 by 3 matrix \(A_\theta\). The six entries of \(A_\theta\) are the six numbers the localisation network has to produce. Those six numbers cover cropping, translation, rotation, scale and skew. A more constrained form, with only s, t_x and t_y, covers cropping, translation and isotropic scaling.
Any parameterised transform works if it's differentiable with respect to its parameters, such as a projective or thin plate spline transform.
Sampling and gradients
Each output value is a kernel-weighted sum of input values around its sampling point. The integer kernel is the simplest choice, since it copies the nearest input pixel. The bilinear kernel weights the four surrounding pixels by max(0, 1 - |distance|) in each direction. Because the kernel has corners, the derivative with respect to the sampling coordinates has to be a sub-gradient.
Gradients flow back to the input feature map through the kernel weights, as in equation (6). They also flow to the sampling coordinates through the kernel's partial derivatives, as in equation (7). From the coordinates they reach the transformation parameters and then the localisation network. The same sampling is applied to every channel, which keeps the channels spatially aligned.
On a GPU, each output pixel only sums over its kernel support instead of over all input locations.
Distorted MNIST results
The authors compared FCN and CNN baselines with ST-FCN and ST-CNN on rotated, RTS, projective and elastic MNIST. All models had about the same number of parameters and identical optimisation, and the spatial transformer networks used bilinear sampling. The spatial transformers used an affine, a projective or a 16-point thin plate spline transform.
On RTS, the affine ST-CNN scored 0.5% percentage error, compared to 0.8% for the CNN. The ST-FCN, with no convolution or max-pooling at all, scored 0.8% on the same task. The authors read this as a warp being an alternative route to spatial invariance.
On 60 by 60 images with translated digits and background clutter, the FCN got 13.2% error. The CNN got 3.5%, the ST-FCN 2.0% and the ST-CNN 1.7%. The ST-CNN beat the ST-FCN, which the authors attribute to max-pooling and convolution adding spatial invariance and local structure.
The authors explain this by the thin plate spline reshaping each digit into a prototype, which lowers the difficulty for the classifier. They also note that the thin plate spline model doesn't overfit on simpler data such as rotation.
SVHN and CUB results
On SVHN, the task is to recognise the digit sequence in around 200k real house-number images. The baseline is a character sequence CNN with 11 hidden layers and five softmax classifiers. ST-CNN Multi puts a spatial transformer before each of the first four convolutional layers.
On 64 by 64 crops, ST-CNN Multi scored 3.6% sequence error, compared to 3.9% for the previous best. On 128 by 128 crops, the ST-CNN got 3.9%, compared to 4.5% for the recurrent attention model DRAM. The authors stress that the ST-CNN is one model in a single forward pass, while the DRAM result averages models.
ST-CNN Multi is 6% slower than the CNN in the forward and backward pass. This is a single speed figure, measured only for ST-CNN Multi against the CNN on SVHN.
On CUB-200-2011, the authors use 2 or 4 parallel transformers on the image, each feeding an Inception part stream. Only image class labels are used for training.
The ImageNet training set and the CUB test set overlap by 22/5794 images. Removing those images from the test set leaves 84.0% with the same ST-CNN.
In the predicted transforms, one transformer learns to detect heads and another fixates on the body. The authors contrast this with earlier work that defined bird parts using supplied keypoint data. Here the part detectors are learned from image labels alone.
Limitations
Downsampling with a fixed, small kernel such as bilinear can cause aliasing. In a purely feed-forward design, the number of parallel transformers caps how many objects the network can model. The authors explore only feed-forward networks, and they mention recurrent use only as early experiments.
Sub-gradients are needed because the sampling functions are discontinuous. The ImageNet overlap is small, and the 84.0% result without those images is the check the authors report.
Paper info
- Authors
- Max Jaderberg, Karen Simonyan, Andrew Zisserman, Koray Kavukcuoglu
- Venue
- arXiv · Preprint
- First published
- 2015-6-5
- Added
- 2026-11-11
- Updated
- 2016-2-4
- Version
- v3
- arXiv
- 1506.02025
- Category
- cs.CV
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Max Jaderberg, Karen Simonyan, Andrew Zisserman, Koray Kavukcuoglu (2015). Spatial Transformer Networks. arXiv:1506.02025v3. https://arxiv.org/abs/1506.02025v3
BibTeX
@misc{jaderberg2015spatial,
title = {{Spatial Transformer Networks}},
author = {Max Jaderberg and Karen Simonyan and Andrew Zisserman and Koray Kavukcuoglu},
year = {2015},
eprint = {1506.02025},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1506.02025v3}
}