A Memory Transformer Network for Incremental Learning

Ahmet Iscen, Thomas Bird, Mathilde Caron, Alireza Fathi, Cordelia Schmid

TL;DR

The Memory Transformer Network (MTN) rethinks how we use "exemplars" in class-incremental learning. Instead of just using a small memory bank of old data to retrain the model (rehearsal), MTN uses a lightweight transformer to explicitly compare new queries against these stored examples during inference, setting a new state-of-the-art on large-scale benchmarks like ImageNet-1k.

What Problem Does This Paper Address?

In Class-Incremental Learning (CIL), a model must learn new categories of data over time without losing the ability to recognize old ones. The primary hurdle is catastrophic forgetting: when a neural network is tuned for new tasks, the weights representing old tasks are often overwritten.

The standard "gold standard" for fighting this is rehearsal. Researchers keep a tiny "memory bank" of representative images (exemplars) from previous tasks and mix them into the training data for new tasks. However, most methods only use this memory during training. During inference (prediction), the model relies solely on its internal weights. The authors argue this is a missed opportunity—why not use that explicit memory bank as a reference during the actual prediction?

Methods

The authors introduce the Memory Transformer Network (MTN). The architecture works in four main steps:

  1. Feature Extraction: An input image (query) is passed through a backbone (like ResNet-18 or a ViT) to get a feature vector.
  2. Neighborhood Search: The system performs a $k$-Nearest Neighbor ($k$-NN) search to find the $k$ most similar feature vectors currently stored in the exemplar memory bank.
  3. Transformer Aggregation: The query vector and its $k$ neighbors are fed into a lightweight transformer. Unlike standard transformers that process sequences of words, this transformer processes the "local neighborhood" of the query in feature space. It learns to model the relationships between the query and the stored exemplars.
  4. Classification: The transformer outputs an "adapted" feature vector, which is then passed to a final linear layer to produce class probabilities.

By using a separated-softmax loss and task-wise distillation, the model ensures that the transformer learns to balance new information with the preserved knowledge in the memory bank.

Datasets

The model was evaluated on two massive, challenging benchmarks:

  • ImageNet-1k: The standard 1,000-class image classification dataset.
  • Google-Landmarks-1k: A subset of the Google Landmarks v2 dataset, which is often more difficult due to the high intra-class variance of landmark photos.

In both cases, the authors followed a standard incremental setup: starting with 500 base classes and adding the remaining 500 in batches (tasks) of 50, 100, or 250.

Key Insights and Ideas

  • Prediction as an "Open-Book" Exam: Most CIL models treat prediction like a closed-book exam—they must remember everything in their weights. MTN treats it like an open-book exam, where the model can "look up" similar examples in its memory bank to verify its hunch.
  • Explicit vs. Implicit Memory: While model weights store "implicit" patterns, the memory bank stores "explicit" corner cases. MTN allows the model to attend to these specific corner cases directly, which is much more efficient than trying to bake every rare pattern into the global weights.
  • Local Attention is Enough: You don't need to attend to the entire memory bank (which could be 20,000+ images). Attending to just the top 10 neighbors ($k=10$) provides a strong enough signal to significantly boost accuracy while keeping the transformer computationally "light."
  • Correcting the $k$-NN: A simple $k$-NN classifier often fails if the closest neighbor happens to be an outlier. The transformer is smarter; it can learn to "up-weight" a neighbor that is slightly further away but provides a more consistent class signal (see Figure 5 in the paper).

Key Results

  • State-of-the-Art Performance: MTN consistently outperformed existing methods like iCaRL, LUCIR, and SS-IL. On ImageNet-1k (with 100-class increments), MTN achieved an average incremental accuracy of 70.7%, compared to 67.5% for the previous best baseline (SS-IL).
  • Efficiency with Small Memory: MTN is remarkably robust to memory constraints. Even when the memory size ($M$) was reduced significantly, MTN's accuracy dropped much more slowly than standard rehearsal methods.
  • Qualitative Wins: The authors showed examples where a standard $k$-NN search would have picked the wrong class (e.g., mistaking a "duck" for a "red-breasted merganser"), but the MTN transformer correctly identified the query by aggregating information across the whole neighborhood.

Limitations and Future Work

  • Inference Latency: Performing a $k$-NN search and a transformer pass for every single prediction adds computational overhead compared to a simple linear classifier. While the authors used a "lightweight" transformer, this might still be a bottleneck for real-time mobile applications.
  • Fixed Features: Much of the study used "fixed" features (pre-trained SimCLR or CLIP backbones). While this is a common practice to isolate the performance of the classifier, the authors note that training the entire system end-to-end in an incremental fashion is a logical next step.
  • Exemplar Selection: The paper uses a standard "Ringbuffer" method to choose which images to keep. Future work could explore if the transformer's attention weights could be used to more intelligently select which exemplars are "most useful" to save.

Summary updated

BibTeX
@inproceedings{iscen2022memory,
  author = {Ahmet Iscen and Thomas Bird and Mathilde Caron and Alireza Fathi and Cordelia Schmid},
  title = {{A Memory Transformer Network for Incremental Learning}},
  booktitle = {BMVC},
  year = {2022},
  url = {https://openreview.net/forum?id=4u-t8CdRTtX},
}

Loading related content...

Figure