Low-Shot Learning with Imprinted Weights

Hang Qi, Matthew Brown, David G. Lowe

TL;DR

This paper introduces weight imprinting, a simple yet powerful technique to instantly add new categories to a pre-trained ConvNet by directly setting the final layer weights using the embeddings of just a few training examples. By bridging the gap between softmax classifiers and metric learning, it provides immediate recognition capabilities and serves as a superior initialization for subsequent fine-tuning.

What Problem Does This Paper Address?

Standard deep learning models are "data-hungry" and struggle with low-shot learning—the ability to learn new concepts from only one or a few examples, a feat humans perform effortlessly.

Typically, adding new classes to a trained ConvNet requires extensive fine-tuning with stochastic gradient descent (SGD), which is computationally expensive and risks "forgetting" old classes. Alternatively, metric learning (embedding) methods allow for adding new classes via nearest-neighbor search, but these require storing all training embeddings and can be slow during inference. The authors seek a middle ground: a method that retains the efficient parametric form of a standard classifier while gaining the rapid learning flexibility of embedding methods.

Methods

The core innovation is a two-step process called imprinting, built on a specific architectural modification.

  1. Architecture Modification: The authors add an $L_2$ normalization layer at the end of the embedding extractor (the penultimate layer). They also normalize the weights of the final fully-connected (FC) layer to unit length and remove the bias term. This ensures that the inner product between an input embedding and a class weight vector is equivalent to cosine similarity. To aid convergence, a trainable scaling factor $s$ is applied before the softmax.
  2. Weight Imprinting: When a new category is introduced with a single example $x_+$, the model computes its embedding $\phi(x_+)$ and directly sets this vector as the new column in the weight matrix for that class ($w_+ = \phi(x_+)$).
  3. Averaging for Multi-Shot: If multiple examples are available, the weights are set to the average of their normalized embeddings and then re-normalized.
Figure 1. The overall architecture of imprinting. After a base clas- sifier is trained, the embedding vectors of new low-shot examples are used to imprint weights for new classes in the extended classi- fier.

This process exploits the symmetry between normalized inputs and weights, effectively "remembering" the new class's location in the embedding space as a template.

Figure 2. Illustration of imprinting in the normalized embedding space. (a) Before imprinting, the decision boundaries are deter- mined by the trained weights. (b) With imprinting, the embedding of an example (the yellow point) from a novel class defines a new region.

Datasets

The authors evaluated their approach on the CUB-200-2011 dataset, a challenging benchmark for fine-grained bird classification containing 200 categories. They split the data into 100 "base" classes (with abundant data) and 100 "novel" classes (with only $n=1, 2, 5, 10, 20$ examples).

Key Insights and Ideas

  • Symmetry is Key: By normalizing both embeddings and weights, the authors turn the final layer into a template matcher. This allows them to treat activations and weights interchangeably.
  • Averaging as a Denoising Filter: Surprisingly, averaging embeddings for a new class performs better than storing all individual instances for a nearest-neighbor search. The authors conjecture that averaging reduces noise in the embedding dimensions, focusing on features consistent for that category.
  • Superior Initialization: Imprinted weights provide a much better starting point for SGD than random initialization. It bypasses the initial "random walk" phase of training, leading to faster convergence and higher final accuracy, especially in extremely low-data regimes (1-5 shots).
  • Unified Framework: The method allows a single model to perform well on both old (base) and new (novel) classes simultaneously without needing to cycle through all old data extensively.

Key Results

  • Instant Recognition: On CUB-200-2011, a 1-shot imprinted model achieved 21.26% accuracy on novel classes instantly, compared to near-zero for random initialization.
  • Fine-tuning Boost: When fine-tuned, the imprinted model reached higher accuracies much faster. For example, with 5 shots, imprinting + fine-tuning reached ~46% accuracy on novel classes, significantly outperforming random initialization + fine-tuning (~35%).
Figure 3. Accuracy of fine-tuned models on novel classes for the first 40 epochs of training. Table 1 lists results after 112 epochs.
  • Qualitative Success: The model successfully generalized from single exemplars to recognize birds in different poses and backgrounds, particularly for categories with distinctive colors or textures.
Figure 5. (a) A subset of exemplars used for 1-shot training of novel classes sorted by their recall@1 scores as shown below each exemplar. High-performing categories tend to exhibit more distinctive colors, shapes, and/or textures. (b) Randomly selected success and failure cases predicted by a 1-shot imprinted model on CUB-200-2011. Test images and the 1-shot exemplar whose embedding was used to imprint the predicted class are shown in separate rows. Correct and wrong predictions are marked with green and red borders, respectively.

Limitations and Future Work

  • Unimodal Assumption: The averaging strategy assumes that a class's distribution in the embedding space is unimodal (has one "cluster"). This might fail for categories with high intra-class variance (e.g., a class containing both male and female birds that look very different).
  • Embedding Quality: The method's success relies heavily on the quality of the pre-trained embedding space. If the base classes don't share features with the novel classes, imprinting will be less effective.
  • Future Directions: The authors suggest exploring whether imprinting can be applied to lower layers of the network to learn novel low-level features more rapidly.

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