Low-Shot Learning With Imprinted Weights

Hang Qi, Matthew Brown, David G. Lowe

Abstract

Human vision is able to immediately recognize novel visual categories after seeing just one or a few training examples. We describe how to add a similar capability to ConvNet classifiers by directly setting the final layer weights from novel training examples during low-shot learning. We call this process weight imprinting as it directly sets weights for a new category based on an appropriately scaled copy of the embedding layer activations for that training example. The imprinting process provides a valuable complement to training with stochastic gradient descent, as it provides immediate good classification performance and an initialization for any further fine-tuning in the future. We show how this imprinting process is related to proxy-based embeddings. However, it differs in that only a single imprinted weight vector is learned for each novel category, rather than relying on a nearest-neighbor distance to training instances as typically used with embedding methods. Our experiments show that using averaging of imprinted weights provides better generalization than using nearest-neighbor instance embeddings.

Introduction

Standard deep learning models are notoriously data-hungry, typically requiring thousands of labeled examples and extensive iterative gradient descent (fine-tuning) to learn new categories. This poses significant challenges in terms of latency—fine-tuning on edge devices is computationally expensive—and catastrophic forgetting, where new learning degrades performance on previously learned base classes. In contrast, humans exhibit "low-shot learning," recognizing novel objects after a single exposure. This paper introduces "weight imprinting," a technique that allows convolutional neural networks (ConvNets) to expand their vocabulary instantly without retraining the entire system.

Methodology: Weight Imprinting

The core innovation lies in how the final classification layer is updated. In a standard ConvNet, the last layer is a linear transformation that multiplies an image embedding by a weight matrix. The authors propose two critical architectural modifications to facilitate imprinting:

  1. Normalization: An $L_2$ normalization layer is added to the embedding, and weights in the final layer are also constrained to unit length. This effectively converts the standard dot product into a cosine similarity measure.
  2. Scale Factor ($s$): Since cosine similarity is bounded between -1 and 1, a trainable scale factor is introduced to "stretch" these values, allowing the softmax function to produce high-confidence probabilities during initial training.

The Imprinting Process

When a novel class is introduced, the model performs a single forward pass on the training image(s) to extract the embedding vector. Instead of random initialization followed by backpropagation, the model copies this embedding vector directly into the weight matrix for the new class. If multiple examples are available, their embeddings are averaged. This process creates "templates" or "prototypes" in the feature space that represent the new categories.

Overview of the weight imprinting process for extending a classifier with novel categories.

Experimental Setup

The approach was evaluated using the CUB-200-2011 dataset, featuring 200 fine-grained bird categories. The first 100 classes served as "base classes" to train the initial embedding extractor. The remaining 100 "novel classes" were introduced using $n$ examples, where $n$ ranged from 1 to 20.

Key Results

The imprinting method demonstrates significant advantages in both immediate performance and long-term learning:

  • Instant Recognition: In a 1-shot scenario, the imprinted model achieved 21.26% accuracy on novel classes immediately, compared to near 0% for random initialization.
  • Superior Initialization: Imprinting provides a far better starting point for subsequent fine-tuning. As shown in the performance analysis, models initialized with imprinted weights consistently outperform those with random initialization across various shot counts and training epochs.
  • Efficiency: Adding a new class requires only a single forward pass, making it orders of magnitude faster than traditional transfer learning.
Top-1 Accuracy over training epochs comparing weight imprinting versus random initialization for different shot counts.

Discussion and Conclusion

Weight imprinting leverages the symmetry created by normalized embeddings and weights to treat classifier weights as prototypes in feature space. A key finding is that averaging embeddings into a single imprinted weight vector generalizes better than traditional nearest-neighbor approaches that store every instance, as it helps filter out instance-specific noise.

While highly effective, the method assumes that classes are unimodal (clustering around a single point). Future work may explore handling multimodal categories and applying imprinting to deeper layers of the network for more fundamental rapid adaptation.

Summary updated

BibTeX
@inproceedings{qi2018low,
  author = {Hang Qi and Matthew Brown and David G. Lowe},
  title = {{Low-Shot Learning With Imprinted Weights}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2018},
  url = {https://openreview.net/forum?id=By-xnyz_WH},
}
Figure