Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Learning to Compare: Relation Network for Few-Shot Learning

Relation Network learns a comparison rule for few-shot image classification

  • Problem Few-shot classifiers must recognise new classes from only one or a few examples each. Fine-tuning and fixed distance rules such as Euclidean distance struggle when so little labelled data is available.
  • Method The Relation Network trains an embedding module and a learned relation module together, end to end from scratch. Instead of a fixed distance, it scores each query-sample pair on episodes that mimic the test task.
  • Results The network reached 99.6 ± 0.2% 5-way 1-shot accuracy on Omniglot and 50.44 ± 0.82% on miniImagenet, with no fine-tuning at test time.

Why few-shot recognition is hard for standard training

Few-shot recognition asks a classifier to recognise classes from only one or a few labelled examples each. Under that limited data, the standard practice of fine-tuning a deep network on the target classes is hard to apply, and data augmentation and regularisation reduce overfitting without removing it. Many existing methods therefore move the heavy lifting into an auxiliary meta-learning phase, where knowledge is learned for good initial weights, for embeddings, or for optimisation strategies.

Several of these methods still rely on complex machinery. Some use complex inference, some use recurrent memory architectures, and some fine-tune on the target problem, which adds cost at test time. The metric-learning family is the closest to this work, because it learns a transferable embedding and then compares samples with a fixed rule such as Euclidean distance.

The Relation Network keeps the embedding learning but learns the comparison rule as well.

How the Relation Network scores a pair

The Relation Network has two branches. An embedding module \(f_\phi\) maps every sample image and every query image to a feature map, and a relation module \(g_\varphi\) decides how well a sample matches a query. For one query \(x_j\) and the sample \(x_i\), the two feature maps are concatenated in depth by the operator \(\mathcal{C}\). The relation module then produces the score.

The one-shot relation score is given by \[ r_{i,j} = g_\varphi\big(\mathcal{C}(f_\phi(x_i), f_\phi(x_j))\big), \quad i = 1, 2, \ldots, C \] so a C-way problem yields C scores per query. The relation module ends in a sigmoid output, which keeps each score in the range 0 to 1.

For K-shot tasks with K greater than one, the embedding outputs of all samples from one class are summed element-wise into a single class-level feature map. That map is then combined with the query feature map as in the one-shot case, so the number of scores per query remains C. Because the learned comparator is trained jointly with the embedding, the features need not be separable by a fixed metric; the comparison is learned as part of the same network.

Once trained, the network classifies query images from new classes by computing their relation scores against the few examples of each new class, with no further weight updates. Because each target problem is solved by a single feed-forward pass, the approach avoids the model updates that fine-tuning-based methods require at test time.

Episodes and the regression objective

Training follows an episode-based scheme. Each episode draws C classes from the training set, takes K labelled samples per class as the sample set, and uses the remaining samples of those classes as the query set. This split is meant to mirror the support and test split that appears at evaluation time.

The model is trained by minimising a squared error between each relation score and its target, where the target is 1 when the sample and query share a label and 0 otherwise. The objective is \[ \min_{\phi,\varphi} \sum_{i=1}^{m} \sum_{j=1}^{n} \big(r_{i,j} - \mathbf{1}(y_i == y_j)\big)^2 \] where m is the number of samples in the sample set and n is the number of queries.

The authors note that a label space of 0 and 1 suggests classification, but they treat the task as regression of relation scores, because the ground truth can only take those two values.

Few-shot training uses Adam with an initial learning rate of 10−3, halved every 100,000 episodes, and all models are trained end to end from scratch.

Layer sizes and episode composition

The embedding module uses four convolutional blocks with 64 filters of size 3×3. Each block has batch normalisation and a ReLU, and the first two blocks also apply 2×2 max-pooling. The relation module uses two convolutional blocks, each with 64 filters of size 3×3 followed by batch normalisation, ReLU and 2×2 max-pooling, then two fully connected layers of 8 and 1 units.

The flattened relation input has size H = 64 for Omniglot and H = 64 × 3 × 3 = 576 for miniImageNet.

On Omniglot, each class contains 20 samples, and the authors use 1200 classes plus rotations for training and 423 classes plus rotations for testing, with inputs resized to 28×28. In each Omniglot training episode the 5-way 1-shot setting uses 19 query images per class, the 5-way 5-shot setting uses 15, the 20-way 1-shot setting uses 10, and the 20-way 5-shot setting uses 5.

For miniImagenet, inputs are resized to 84×84 and the split is 64 training, 16 validation and 20 test classes, and the validation classes are used only to monitor generalisation. In each miniImagenet training episode, the 5-way 1-shot setting uses 15 queries per class and the 5-way 5-shot setting uses 10.

Few-shot results on Omniglot and miniImagenet

On Omniglot, the Relation Network reached 99.6 ± 0.2% in the 5-way 1-shot setting, the highest value in that column, and 97.6 ± 0.2% in the 20-way 1-shot setting, above Meta Nets at 97.0%. Accuracies are averages over 1000 randomly generated test episodes.

In the 5-way 5-shot setting on Omniglot, the Relation Network reached 99.8 ± 0.1%, which is 0.1% below MAML at 99.9 ± 0.1%. The authors note that MAML fine-tunes on the target problem, whereas the Relation Network does not. In the 20-way 5-shot setting it reached 99.1 ± 0.1%, against 98.9 ± 0.2% for MAML.

On miniImagenet, the Relation Network reached 50.44 ± 0.82% in 5-way 1-shot, above Prototypical Nets at 49.42 ± 0.78%. In 5-way 5-shot it reached 65.32 ± 0.70%, below Prototypical Nets at 68.20 ± 0.66%. These figures are averages over 600 test episodes.

The comparison is not like for like in training budget. The reported Prototypical Nets 1-shot result was trained on 30-way episodes with 15 queries and its 5-shot result on 20-way episodes, while the Relation Network was trained on 5-way episodes with one query for 1-shot and five queries for 5-shot. When Prototypical Nets was trained with 5-way 15-query episodes, the authors report 46.14 ± 0.77% for 1-shot evaluation, which they describe as clearly weaker than the Relation Network.

Replacing the sample image with a class description

In zero-shot learning each class is defined by a semantic class embedding vector instead of one support image. The sample branch therefore embeds that vector with a second, heterogeneous embedding module, while the query image goes through the image embedding module. The relation score is then \[ r_{i,j} = g_\varphi\big(\mathcal{C}(f_{\phi_1}(v_c), f_{\phi_2}(x_j))\big), \quad i = 1, 2, \ldots, C \] where \(v_c\) is the class vector and \(x_j\) is the query image, and the objective is the same as in few-shot learning.

The image branch uses an existing deep network pretrained on ImageNet, such as Inception or ResNet, so the zero-shot model is not trained from scratch in the same way as the few-shot model. For the old and conventional setting the image embedding is Inception-V2, and for the GBU and generalised settings it is ResNet101, with top pooling units giving dimensions of 1024 and 2048.

Zero-shot results under the two settings

Under the old setting, where test data come only from unseen classes, the authors compare 15 alternative approaches and consider only inductive methods. The Relation Network reached 62.0 hit@1 accuracy on CUB, which is above the other listed methods, including SAE at 61.4 and Prototypical Nets at 54.6, and 84.5 on AwA, which is competitive but below SAE at 84.7 and DEM at 86.7.

The authors attribute the CUB gain partly to the fact that the attribute vector is the only sample class embedding in their model.

Under the GBU setting, the authors compare with 11 alternative zero-shot models, and the reported DEM result is taken from its authors' code page. Under generalised zero-shot learning, the Relation Network reached an harmonic mean H of 45.3 on AwA2, against 45.1 for DEM, and 47.0 on CUB, against 34.4 for ALE, the next best value in that column.

On AwA1 the harmonic mean H is 46.7, which is below DEM at 47.3, so DEM is the only method that outperforms it on that dataset.

Why a learned relation module helps

Fixed metrics such as Euclidean distance assume that features are compared element by element, so they depend heavily on how discriminative the learned embedding is. A Mahalanobis metric is a shallow learned metric, and adding a further MLP embedding in front of it still does not solve the matching problem in the synthetic example.

In the synthetic example with 2D query and sample embeddings, a Mahalanobis relation module fails to separate matching and mismatching samples, and so does an embedding followed by a Mahalanobis metric. Only the full deep relation module recovers the ground-truth matching region. The example is designed so that the embedding is not discriminative enough for a Euclidean nearest-neighbour comparison, which isolates the effect of the comparator.

On real Omniglot data, the authors qualitatively show that matching samples are not simply the nearest neighbours of a query under Euclidean, cosine or Mahalanobis distance. When the same query-sample pairs are projected by a 2D PCA of the relation module's penultimate layer, matching and mismatching pairs appear linearly separable, which suggests the relation module has mapped the pairs into a more separable space.

Limitations

The relation scores are not guaranteed to be self-similar or symmetric, as a formal similarity function would be. The authors report that these properties hold numerically for a trained Relation Network, but they do not prove them. The regression view of the loss is a modelling choice, since the ground truth takes only the values 0 and 1.

Few-shot results are reported only on Omniglot and miniImagenet, and the miniImagenet 5-way 5-shot result is below Prototypical Nets. On Omniglot 5-way 5-shot the result is 0.1% below MAML, which fine-tunes on the target problem.

Under the old zero-shot setting some test classes also appear in the ImageNet 1K classes used to pretrain the image embedding network, which violates the zero-shot assumption. The GBU setting avoids this overlap. Transductive zero-shot methods, which use all test data at once, were not compared, and on AwA1 under GBU the method is outperformed by DEM.

Paper info

Authors
Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip H. S. Torr, Timothy M. Hospedales
Venue
arXiv · Preprint
First published
2017-11-16
Added
2026-11-12
Updated
2018-3-27
Version
v2
arXiv
1711.06025
Category
cs.CV
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip H. S. Torr, Timothy M. Hospedales (2017). Learning to Compare: Relation Network for Few-Shot Learning. arXiv:1711.06025v2. https://arxiv.org/abs/1711.06025v2

BibTeX
@misc{sung2017learning,
  title = {{Learning to Compare: Relation Network for Few-Shot Learning}},
  author = {Flood Sung and Yongxin Yang and Li Zhang and Tao Xiang and Philip H. S. Torr and Timothy M. Hospedales},
  year = {2017},
  eprint = {1711.06025},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1711.06025v2}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up