Abstract
We present a conceptually simple, flexible, and general framework for few-shot learning, where a classifier must learn to recognise new classes given only few examples from each. Our method, called the Relation Network (RN), is trained end-to-end from scratch. During meta-learning, it learns to learn a deep distance metric to compare a small number of images within episodes, each of which is designed to simulate the few-shot setting. Once trained, a RN is able to classify images of new classes by computing relation scores between query images and the few examples of each new class without further updating the network. Besides providing improved performance on few-shot learning, our framework is easily extended to zero-shot learning. Extensive experiments on five benchmarks demonstrate that our simple approach provides a unified and effective approach for both of these two tasks.
Introduction
Standard deep learning models are notoriously data-hungry, requiring thousands of labeled examples to recognize new categories. In contrast, humans can learn a new concept from a single example. This gap is the focus of Few-Shot Learning (FSL). Existing FSL approaches often use "meta-learning," where a model is trained on many small tasks (episodes) to learn how to learn. However, many of these methods rely on pre-defined, fixed distance metrics (like Euclidean or Cosine distance) to compare a new "query" image to a few labeled "sample" images. The authors argue that these fixed metrics are too restrictive. They propose that the metric itself should be a deep, non-linear function learned directly from the data.
The Relation Network (RN) is a framework that learns to perform few-shot and zero-shot learning by "learning to compare." Instead of relying on fixed distance metrics, it uses a deep neural network to learn a non-linear similarity function, achieving state-of-the-art results across multiple benchmarks.
Methods
The Relation Network consists of two main components:
- Embedding Module ($f_\phi$): A convolutional neural network (CNN) that extracts feature maps from both the sample images (the few examples available) and the query image (the one to be classified).
- Relation Module ($g_\varphi$): This module takes the concatenated feature maps of a sample and a query and processes them through further convolutional and fully connected layers to produce a relation score between 0 and 1.
The model is trained end-to-end using an episode-based strategy. In each training step, the model sees a "mini-task" mimicking the few-shot setting. It uses Mean Square Error (MSE) loss to regress the relation score toward 1 for matching pairs and 0 for mismatched pairs. This setup is flexible enough to handle Zero-Shot Learning (ZSL) as well, by replacing the sample image embedding with a semantic class description, such as an attribute vector.
Key Insights and Ideas
A primary distinction of this work is the shift from learning a better embedding space for a fixed metric to learning a better comparator. Most previous metric-learning papers focused on the former. The RN focuses on the latter, emphasizing that non-linearity is essential. A fixed linear metric assumes that classes are linearly separable in the embedding space. The authors demonstrate with a synthetic "spiral" dataset that the Relation Network can learn complex, non-linear boundaries that fixed metrics simply cannot capture.
By using a deep relation module, the model incorporates a deep inductive bias, allowing it to learn a more generalisable solution to the problem of comparing objects. Furthermore, the RN is highly efficient; unlike meta-learning methods like MAML, it does not require fine-tuning or gradient updates at test time, classifying new images in a single feed-forward pass.
Experimental Results
The authors evaluated the Relation Network on several primary benchmarks for both few-shot and zero-shot learning:
- Few-Shot Learning:
- Omniglot: Achieved 99.6% accuracy in 5-way 1-shot tasks and 97.6% in 20-way 1-shot tasks, setting a new state-of-the-art at the time.
- miniImageNet: Reached 50.44% accuracy for 1-shot learning, outperforming Matching Nets and Prototypical Networks.
- Zero-Shot Learning:
- Animals with Attributes (AwA): Evaluated using images of 50 animal classes with 85-dimension attribute vectors.
- Caltech-UCSD Birds-200-2011 (CUB): On this dataset of 200 bird species, the RN achieved 62.0% accuracy, significantly outperforming the previous best of 54.6%.
Discussion and Limitations
While the Relation Network provides a powerful and unified approach, there are areas for further exploration. The use of MSE loss for a classification task is non-standard, although it proved effective in this architecture. Additionally, scalability may be a concern in "many-way" settings, as the relation module must compare every query image against every sample class. Finally, performance is sensitive to the architecture of the embedding and relation modules; subsequent research has shown that using more powerful backbones like ResNet can further enhance results.
Summary updated