# Recurrent Models of Visual Attention

Recurrent attention models classify cluttered images by looking at selected regions

Volodymyr Mnih, Nicolas Heess, Alex Graves, Koray Kavukcuoglu · arXiv · 2014-6-24

- **Problem** Convolutional networks spend computation on every pixel, so their cost grows with image size. Their hidden layers also grow with the input, and clutter around an object is processed in full.
- **Method** The Recurrent Attention Model is an RNN that reads one low-resolution glimpse per step. It picks the next location, trained with REINFORCE, and classifies with cross entropy.
- **Results** On 60x60 Cluttered Translated MNIST, RAM with 4 glimpses reaches 7.1% error against 7.83% for the convolutional network.

## Cost of scanning full images

Convolutional detectors pay for every pixel, so their cost grows at least proportionally with the pixel count. Sliding-window detectors apply a classifier to thousands of crops, so a single test image can take seconds on one GPU. Large convolutional networks also take days to train on several GPUs, even when the inputs are downsampled.

Human perception avoids processing a whole scene at once. Attention is directed to selected parts of the visual field, and information from successive fixations is combined over time. Restricting computation to a region saves bandwidth, and it also removes clutter outside that region from the task.

Earlier attention work includes classifier cascades, branch-and-bound search and candidate window proposals, but these stay tied to the window classifier and use past information only to a limited degree. Saliency detectors rely on low-level contrast, are largely hardwired and rarely integrate information across fixations.

## Attention as a sequential decision

The model treats attention as a goal-directed agent that sees the environment only through a bandwidth-limited sensor and never senses all of it. Each step yields a scalar reward, which may be sparse and delayed, and the agent aims to maximise the total reward. The same framing covers static classification, where the environment action is the label and the reward signals a correct decision, and game play, where actions are joystick moves.

Because the agent sees only partial observations, the setting is a Partially Observable Markov Decision Process, and the policy is a function of the history of glimpses and actions. In this model the history is summarised in the hidden state of the recurrent network, so the policy is defined directly by the RNN.

## Glimpses, the glimpse network and the core

The glimpse sensor extracts a retina-like encoding \\( \\rho(x\_t, l\_{t-1}) \\) centred on the previous location, with high resolution near the centre and coarser resolution further out. The retina encoding takes \\( k \\) square patches centred at the location. The first patch is \\( g\_w \\times g\_w \\) pixels, each successive patch is twice the width of the previous one, and all patches are resized to \\( g\_w \\times g\_w \\) and concatenated.

The glimpse network maps the retina encoding and the location through two separate rectifier branches and then combines them with a further linear layer, giving the glimpse feature \\( g\_t \\). Concretely, \\( g = \\mathrm{Rect}(\\mathrm{Linear}(h\_g) + \\mathrm{Linear}(h\_l)) \\), where \\( h\_g = \\mathrm{Rect}(\\mathrm{Linear}(\\rho(x,l))) \\) and \\( h\_l = \\mathrm{Rect}(\\mathrm{Linear}(l)) \\).

The hidden dimensions of \\( h\_g \\) and \\( h\_l \\) are 128 and the output \\( g \\) has dimension 256.

The core network carries the internal state forward. For the classification experiments it is a rectifier network, \\( h\_t = \\mathrm{Rect}(\\mathrm{Linear}(h\_{t-1}) + \\mathrm{Linear}(g\_t)) \\). The location network outputs the mean of a two-component Gaussian with fixed variance, \\( f\_l(h) = \\mathrm{Linear}(h) \\), and the action network is a linear softmax classifier.

## Training with policy gradients and a supervised term

The parameters are the glimpse, core and action networks, and they are chosen to maximise the expected total reward \\( J(\\theta) = E\_{p(s\_{1:T};\\theta)}\[R\] \\). Because sampling the sensor and the actions is not differentiable, the gradient is estimated from sampled interaction sequences with the REINFORCE rule, \\( \\nabla\_\\theta J \\approx \\frac{1}{M}\\sum\_{i}\\sum\_{t}\\nabla\_\\theta \\log \\pi(u^i\_t \\mid s^i\_{1:t};\\theta)R^i \\).

To reduce variance, the reward is centred by a baseline \\( b\_t \\) that depends on the history but not on the current action, and the baseline is learned by reducing the squared error to the observed returns. Where the correct label is known, as in object classification, the action output is trained with cross entropy on the true label, and gradients are backpropagated through the core and glimpse networks.

The location network is always trained with REINFORCE, so the two signals are combined in one training process.

The policy-gradient procedure is also applicable to the extra stop and scale actions the authors mention, but they are only described as an extension.

## Common experimental settings

The classification attention models use a 256-dimensional RNN state and a linear softmax action network. They are trained with stochastic gradient descent using momentum 0.9, and the learning rate and the location-policy variance were chosen by random search. The reward is 1 at the last time step if the classification is correct and 0 otherwise, with 0 for all earlier steps.

## Centred digit classification

Centred MNIST digits were classified with an 8x8 retina, which is too small to show a whole digit, so the single-glimpse model sees one random patch. Test error falls as glimpses are added, with 1.29% reached at 6 glimpses. The table reports 1.35% for the two-layer fully connected baseline with 256 hidden units per layer. The authors read this as evidence that the model learns to combine information from multiple glimpses, and the single-glimpse error of 42.85% shows that one patch is insufficient.

## Translated digits and a convolutional baseline

Translated MNIST places a digit at a random location in a larger blank patch, and training cases are generated on the fly from a training set of 50000 examples multiplied by the possible locations. The authors attribute the gain at 6 and 8 glimpses to the ability to focus the retina on the digit and thus learn a translation-invariant policy.

## Cluttered digits and the effect of image size

Cluttered Translated MNIST adds random 8x8 subpatches from other digits to the image, so the classifier must find the complete digit among clutter. On 60x60 with 4 pieces of clutter, RAM with 4 glimpses reaches 7.1% error against 7.83% for the convolutional network, and RAM with 8 glimpses reaches 5.23%. The authors conclude that attention may cope better with clutter because it can avoid looking at irrelevant regions, since the relative gain over the convolutional network is larger in clutter.

On 100x100 with 8 pieces of clutter, RAM with 8 glimpses on 12x12 patches at 4 scales reaches 10.83% error, while the convolutional baseline reaches 16.51%. The authors point out that the capacity and computation of RAM stay fixed as the image grows, whereas the convolutional hidden layer grows with the number of input pixels.

The learned glimpse paths in these tasks avoid empty or noisy regions and concentrate on the object. The paper's sample policies are shown in its figures, and the paths are described as tracing the object while skipping clutter.

## Learning to track a ball in Catch

Catch is played on a 24x24 binary screen, where a one-pixel ball falls and bounces off the sides, and a two-pixel paddle at the bottom must catch it. The agent sees a 6x6 retina at three scales, so to know the ball's exact position it must capture the ball in the highest-resolution region.

Each agent was trained for 20 million frames, and the best agent catches the ball roughly 85% of the time.

## Limitations

The model is not differentiable through its location decisions, so training depends on the policy-gradient rule rather than direct backpropagation. The discrete alternative for glimpse locations was hard to learn beyond about 25 locations, which is why the continuous Gaussian location policy was used. Experiments cover digit classification on MNIST variants and a single Catch game, and the authors leave large-scale object recognition and video classification as future work.

The tables give one test error per configuration, and the stop action and scale control were only checked in preliminary experiments.

## Paper info

- **Authors**: Volodymyr Mnih, Nicolas Heess, Alex Graves, Koray Kavukcuoglu
- **Venue**: arXiv · Preprint
- **First published**: 2014-6-24
- **Added**: 2026-11-12
- **Updated**: 2014-6-24
- **Version**: v1
- **arXiv**: 1406.6247
- **Category**: cs.LG · cs.CV · stat.ML
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1406.6247v1) · [PDF ↗](https://arxiv.org/pdf/1406.6247v1)

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

Volodymyr Mnih, Nicolas Heess, Alex Graves, Koray Kavukcuoglu (2014). Recurrent Models of Visual Attention. arXiv:1406.6247v1. https://arxiv.org/abs/1406.6247v1

**BibTeX**

```
@misc{mnih2014recurrent,
  title = {{Recurrent Models of Visual Attention}},
  author = {Volodymyr Mnih and Nicolas Heess and Alex Graves and Koray Kavukcuoglu},
  year = {2014},
  eprint = {1406.6247},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1406.6247v1}
}
```

## Other paper commentary

- [Brain Tumor Segmentation with Deep Neural Networks](https://refivu.com/en/papers/f8979d44-9f07-47e9-978e-db57b4a732e6-brain-tumor-segmentation-with-deep-neural-networks.md)
- [Wan: Open and Advanced Large-Scale Video Generative Models](https://refivu.com/en/papers/5df65928-6c5d-44a1-8dc4-c6ec40ae23b4-wan-open-and-advanced-large-scale-video-generative.md)
- [Colorful Image Colorization](https://refivu.com/en/papers/15523601-cc75-4645-8e4f-8d58aa39d74f-colorful-image-colorization.md)
- [Deep Neural Networks are Easily Fooled: High Confidence Predictions for Unrecognizable Images](https://refivu.com/en/papers/f4c978c2-8ce0-412c-af24-4039197ac185-deep-neural-networks-are-easily-fooled-high-confidence.md)
- [BDD100K: A Diverse Driving Dataset for Heterogeneous Multitask Learning](https://refivu.com/en/papers/d564e564-2508-4ec4-987a-011445b39696-bdd100k-a-diverse-driving-dataset-for-heterogeneous.md)
- [The Effectiveness of Data Augmentation in Image Classification using Deep Learning](https://refivu.com/en/papers/dce0e6e2-408a-4750-8e27-0acf7a41b5e6-the-effectiveness-of-data-augmentation-in-image.md)
- [A Survey of the Recent Architectures of Deep Convolutional Neural Networks](https://refivu.com/en/papers/108c5acb-7c6f-4ccb-b4c9-7174cc472551-a-survey-of-the-recent-architectures-of-deep.md)
- [Gated Graph Sequence Neural Networks](https://refivu.com/en/papers/9c16dbd2-8244-4b37-889b-5bd5ba9a31da-gated-graph-sequence-neural-networks.md)
- [Scalable and accurate deep learning for electronic health records](https://refivu.com/en/papers/80cf3810-6b7d-4305-b76c-de501726decd-scalable-and-accurate-deep-learning-for-electronic-health.md)
- [Continual Lifelong Learning with Neural Networks: A Review](https://refivu.com/en/papers/322eae66-d551-4a11-a5e4-5955f903b100-continual-lifelong-learning-with-neural-networks-a-review.md)

## Terms in this paper

- [Stochastic Gradient Descent](https://refivu.com/en/terms/a49650824022-stochastic-gradient-descent)
- [LSTM](https://refivu.com/en/terms/ba10547646d9-lstm)
- [backpropagation](https://refivu.com/en/terms/e09284f057ac-backpropagation)
- [Random search](https://refivu.com/en/terms/4122ba3151ed-random-search)
- [policy gradient](https://refivu.com/en/terms/abaf88e7ce4d-policy-gradient)
- [REINFORCE](https://refivu.com/en/terms/08aa24320e81-reinforce)
- [cross entropy loss](https://refivu.com/en/terms/b16f172737ac-cross-entropy-loss)
- [partially observable Markov decision process](https://refivu.com/en/terms/4e32d4575cd4-partially-observable-markov-decision-process)
- [convolutional network](https://refivu.com/en/terms/ed07a2b625c6-convolutional-network)
- [Reward](https://refivu.com/en/terms/2d2ecca2776a-reward)
- [glimpse](https://refivu.com/en/terms/38868ea21e41-glimpse)
- [fully-connected network](https://refivu.com/en/terms/3dbb121ac9b5-fully-connected-network)
- [Glimpse Network](https://refivu.com/en/terms/b513ac0e435a-glimpse-network)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/e3081a53-9c07-4905-a2ea-84f5e0eae03f-recurrent-models-of-visual-attention)
