A Reinforcement Learning Approach for Sequential Spatial Transformer Networks

Fatemeh Azimi, Federico Raue, Joern Hees, Andreas Dengel

TL;DR

This paper introduces Sequential Spatial Transformer Networks (SSTN), which use Reinforcement Learning (RL) to transform images through a series of discrete steps rather than a single "one-shot" affine transformation. By breaking the problem into a sequence and removing the need for differentiable sampling modules, the authors achieve significantly higher classification accuracy on cluttered datasets compared to traditional Spatial Transformer Networks (STN).

What Problem Does This Paper Address?

In computer vision, a major challenge is making models invariant to geometric changes like rotation, scaling, and translation. Spatial Transformer Networks (STN) were a breakthrough because they allowed a model to learn how to "undo" these transformations—essentially cropping, rotating, or scaling the important part of an image before passing it to a classifier.

However, standard STNs have two main drawbacks:

  1. Differentiability Constraints: They rely on backpropagating gradients through a "sampler" module. This means every part of the transformation process must be mathematically differentiable, which limits the types of transformations and objective functions you can use.
  2. Local Search: STNs try to find the perfect transformation parameters in one go, which can lead to getting stuck in local minima, especially in complex or cluttered images.

Methods

The authors propose treating image transformation as a Markov Decision Process (MDP). Instead of predicting one complex transformation, an RL agent learns to apply a sequence of simple, discrete actions.

  • The MDP Framework:
    • State ($s_t$): A combination of the current transformed image and the previous action taken.
  • Action Space ($A$): 10 discrete moves, including $\pm4$ pixel translations, $\pm10^\circ$ rotations, scaling (zoom), and an "Identity" action to stop the process.
  • Policy Network: The "brain" of the agent. It uses a CNN to extract features and an LSTM (Long Short-Term Memory) to keep track of the sequence of transformations already applied.
  • Training Algorithms: The authors experimented with both Policy Gradient (PG) and Actor-Critic (AC) methods.
  • Reward Design: They tested three reward signals. The most successful was $r_3$, which rewards the agent based on the reduction in classification loss between two consecutive steps.
Fig. 2: SSTN architecture for finding the sequential affine transformation T = Tn · Tn−1 · ... · T0. We compare the performance of different policy architectures with and without using LSTM. The last layer of the policy network is a softmax which outputs the probability distribution of the actions. When using LSTM, the one-hot encoded action from the previous time-step is merged into the feature map of imaget. At each time-step an action corresponding to transformation Ti is sampled from the policy and applied to the image.

Datasets

The model was evaluated on two challenging, noisy benchmarks:

  1. Cluttered MNIST: The classic handwritten digit dataset, but with digits placed randomly in an 80x80 frame filled with random noise/clutter.
  2. Cluttered Fashion-MNIST: A similar setup using clothing items (shirts, shoes, etc.) instead of digits. This is significantly more difficult due to the complexity of the shapes.

Key Insights and Ideas

  • Memory is Essential: The inclusion of an LSTM was a "make or break" design choice. The authors found that a single image doesn't provide enough context for the agent to know what to do next; it needs to "remember" the sequence of actions it has already taken to satisfy the Markovian assumption.
  • Flexibility via RL: Because the system uses RL, the "sampler" (the part that actually warps the image) doesn't need to be differentiable. This allows researchers to use any image processing tool—even non-differentiable ones like morphological operations—as part of the transformation sequence.
  • Dense vs. Sparse Rewards: While a simple $+1/-1$ reward for correct/incorrect classification seems intuitive, the "loss difference" reward ($r_3$) performed better. It provides a denser, more informative signal that helps the agent understand exactly how much each small tweak improved the classifier's "confidence."

Key Results

The SSTN approach consistently outperformed both standard classifiers and the original STN baseline.

Comparison of classification accuracies across different methods.

As shown in the table above:

  • On Cluttered MNIST, the SSTN (using Actor-Critic) reached 96.83% accuracy, outperforming the standard STN's 94.49%.
  • The gap was even wider on the more complex Cluttered Fashion-MNIST, where SSTN achieved 71.61% compared to the STN's 62.54%.
  • The authors also noted that longer "episodes" (more transformation steps) generally led to better accuracy, though this comes with a trade-off in computational speed.

Limitations and Future Work

  • Dataset Complexity: While successful on MNIST-style data, the authors acknowledge the need to test this on more complex, real-world datasets like SVHN or PASCAL VOC.
  • Action Space Expansion: The current model only uses affine transformations. Future work could involve adding more general transformations, such as morphological operations (erosion/dilation) or custom filters.
  • Task Generalization: The authors suggest adapting this sequential approach for other tasks beyond classification, such as object detection.

Summary updated

BibTeX
@inproceedings{azimi2019reinforcement,
  author = {Fatemeh Azimi and Federico Raue and Joern Hees and Andreas Dengel},
  title = {{A Reinforcement Learning Approach for Sequential Spatial Transformer Networks}},
  booktitle = {ICANN},
  year = {2019},
  doi = {10.1007/978-3-030-30487-4\_45},
}

Loading related content...

Figure