Skip to main content
QUICK REVIEW

[Paper Review] A Simple Cache Model for Image Recognition

A. Emin Orhan|arXiv (Cornell University)|May 21, 2018
Adversarial Robustness in Machine LearningComputer Science17 references8 citations
TL;DR

This paper proposes a simple, trainable-free cache mechanism that enhances pre-trained image recognition models at test time by leveraging class-relevant features from intermediate layers near the output. By storing normalized feature representations as keys and one-hot labels as values, and combining them with the network’s softmax output via a weighted fusion, the method achieves significant accuracy gains across multiple architectures and datasets without retraining, while also improving robustness against adversarial attacks.

ABSTRACT

Training large-scale image recognition models is computationally expensive. This raises the question of whether there might be simple ways to improve the test performance of an already trained model without having to re-train or fine-tune it with new data. Here, we show that, surprisingly, this is indeed possible. The key observation we make is that the layers of a deep network close to the output layer contain independent, easily extractable class-relevant information that is not contained in the output layer itself. We propose to extract this extra class-relevant information using a simple key-value cache memory to improve the classification performance of the model at test time. Our cache memory is directly inspired by a similar cache model previously proposed for language modeling (Grave et al., 2017). This cache component does not require any training or fine-tuning; it can be applied to any pre-trained model and, by properly setting only two hyper-parameters, leads to significant improvements in its classification performance. Improvements are observed across several architectures and datasets. In the cache component, using features extracted from layers close to the output (but not from the output layer itself) as keys leads to the largest improvements. Concatenating features from multiple layers to form keys can further improve performance over using single-layer features as keys. The cache component also has a regularizing effect, a simple consequence of which is that it substantially increases the robustness of models against adversarial attacks.

Motivation & Objective

  • To improve the test-time performance of pre-trained image recognition models without retraining or fine-tuning.
  • To address the challenge of rare but distinctive features not well represented in training data by storing them in a cache.
  • To enhance model robustness against adversarial attacks through a regularizing effect of the cache mechanism.
  • To provide a plug-and-play solution compatible with any pre-trained model using only two hyper-parameters.

Proposed method

  • The cache uses key-value pairs where keys are normalized, concatenated activations from one or more layers close to the output layer, and values are one-hot encoded class labels.
  • For a test input, similarity scores between its representation and cached keys are computed using a temperature-scaled dot product (Equation 1).
  • A weighted average of cached values produces a memory-based prediction distribution (Equation 2), which is fused with the network’s original softmax output (Equation 3).
  • The fusion is controlled by a hyper-parameter λ, and the similarity sharpness is controlled by θ, both optimized via grid search on validation data.
  • Keys are extracted from the trained network using a subset of the training data, and no further training is performed on the cache or the main network.
  • The method is applied post-inference, making it architecture-agnostic and easily deployable.

Experimental results

Research questions

  • RQ1Can a pre-trained image classifier achieve improved test-time performance without retraining or fine-tuning?
  • RQ2Does storing intermediate layer features in a cache improve generalization, especially for rare or distinctive features?
  • RQ3Can a simple key-value cache enhance robustness against adversarial examples?
  • RQ4How do the choice of layers and combination of features affect cache performance?
  • RQ5What is the impact of cache size and hyper-parameter tuning on accuracy and robustness?

Key findings

  • The cache model improves top-1 accuracy on CIFAR-10 and CIFAR-100 by up to 4.29% and 6.49% respectively, relative to the baseline model.
  • Using features from layers close to the output layer (e.g., layer 3 in ResNet) yields the largest performance gains, outperforming earlier layers.
  • Concatenating features from multiple layers improves performance over single-layer keys, with the best results achieved using the last few layers.
  • The cache-only variant (λ = 1) achieves 11.87% top-1 accuracy on CIFAR-10 and 39.18% on CIFAR-100 with ResNet20, demonstrating strong generalization.
  • The cache mechanism significantly increases robustness against FGSM and PGD adversarial attacks, indicating a regularizing effect on the model’s input space behavior.
  • The method is effective across multiple architectures (ResNet20, 32, 56) and datasets, including ImageNet, with consistent improvements observed.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.