Few-Shot Learning Using Class Augmentation in Metric Learning
Susumu Matsumi
Meijo University, JapanKeiichi Yamada
Meijo University, Japan193426018@ccmailg.meijo-u.ac.jp

yamadak@meijo-u.ac.jp

Abstract

original training dataclass 1 class 2

We propose a few-shot learning approach based on metric learning in which the number of classes in the training
data to perform metric learning is increased. The numberof classes is augmented by synthesizing samples of imaginary classes at a feature level from original training data.
The approach is evaluated using miniImageNet, and the effectiveness is demonstrated.

...

few-shottest
training
samples samples

class Ctrainset...
...
class augmentation

metriclearning
embedding
function (CNN)...
imaginary imaginary ... imaginaryclass 1class 2class Cgenerated

classifier...

1. Introduction

Figure 1. Overview of the proposed approach.

Few-shot learning is a problem wherein new categories
are learned from only a few samples. Modern few-shotlearning uses prior knowledge from training data in addition to the target few-shot training samples. The main approaches are metric-learning, meta-learning, and data augmentation.
This paper proposes a few-shot learning method basedon metric learning, focusing on increasing few-shot learning performance by increasing the number of classes in thetraining data to perform metric learning. The data augmentation approach used in previous few-shot learning works
expands the number of few-shot training samples. In contrast, we expand the number of classes in the training data
used for metric learning.

via metric learning, with the few-shot samples serving as
the training data, the testing set class is identiﬁed with aclassiﬁer.
In the experiment, we use a CNN consisting of four convolution layers followed by three fully connected layers.
Each convolution layer has a 3 × 3 convolution with 64
ﬁlters, followed by batch normalization, a ReLU activation
function, and a 2×2 max-pooling. The ﬁrst and second fully
connected layers have 4096 and 512 units, respectively.
The samples are combined in the feature map of thefourth convolution layer by taking the element-wise maximum. The output from the ﬁrst fully connected layer isused as an embedding vector. The nearest neighbor method
using cosine similarity is used as the classiﬁer.
The combining method is similar to the mixup [7], However, our method takes the maximum in the feature level anddoes not mix the class labels.

2. Method
Figure 1 outlines the proposed approach. The number ofclasses Ctrainset in the original training set is expanded andthe class-augmented data set is used in metric learning. By
combining samples xa in original training set class c1 andxb in class c2 (̸= c1 ), we generate a new sample xab of animaginary class l(c1 , c2 ) that does not exist in the original
training set.
A convolutional neural network (CNN) is used for metric learning and the trained CNN is used as the embedding
function for few-shot learning. A new sample is synthesizedby combining original samples in a feature map of the CNN
during the CNN training. In the embedding space obtained

3. Experimental Results
The proposed method was evaluated using the miniImageNet [6] following the split introduced by [4]. The images
were resized to 84 × 84 pixels.
First, the accuracy of few-shot learning when all classes
in the original training set (Ctrainset classes) were usedin metric learning was compared with the accuracy form × Ctrainset classes (m < 1) selected at random fromthe original training set. We also compared it with the case1Table 2. Comparison of the performance on miniImageNet withsome existing methods that used four convolutional layers with 64
ﬁlter channels.

0.51

5-way 1-shot

0.5

5-way 5-shot

0.62

0.6

0.48

Accuracy

Accuracy

0.49

0.47
0.46
0.45

Method
0.58

0.56

0.44

Number of classes
Number of samples per class

0.43
0.25

0.5
Expansion rate m

Number of classes
Number of samples per class

0.54
0.25

10.5Expansion rate m

1

Figure 2. Accuracy of few-shot learning when the number ofclasses used in metric learning is decreased and when the numberof samples per class is decreased by the same rate instead of reducing the number of classes. It can be seen that the number ofclasses has a greater impact on the accuracy of few-shot learning
than the number of samples per class.
0.53

0.644

5-way 1-shot

5-way 5-shot

0.642

0.525

0.64

Accuracy

Accuracy

0.52
0.515
0.51

0.638
0.636
0.634
0.632

0.505

0.63

0.5

5-way accuracy (%)
1-shot5-shot

DN4 [1]TPN [2]
Dynamic Few-Shot [3]Meta-Learn LSTM [4]MAML [5]Matching Nets [6]51.24±0.74
55.51±0.8656.20±0.8643.44±0.77
48.70±1.8443.56±0.84

71.02±0.64
69.86±0.65
72.81±0.62
60.60±0.71
63.11±0.9255.31±0.73

Ours (m = 3)

52.57±0.57

64.32±0.47

when the number of classes is increased by 4 times compared to when the number is increased by 3 times. This wasprobably because the difference between the classes wasthen smaller than the difference within each class. Table1 summarizes the performance of the proposed method.
Table 2 shows the comparison of the performance on
miniImageNet with some existing methods that used fourconvolutional layers with 64 ﬁlter channels. Although ourmethod used a simple classiﬁer, it achieved an accuracy
comparable to some of the existing methods.

0.628
123
Class expansion rate m4123
Class expansion rate m

4Figure 3. Accuracy of few-shot learning when the number ofclasses used in metric learning is increased by m times the original
number of classes.
Table 1. Performance of the proposed method on miniImageNet.
methodproposed (m = 3)
baseline (m = 1)

5-way accuracy (%)
1-shot5-shot52.57±0.57
50.39±0.55

64.32±0.47
62.81±0.46

when the number of samples per class was decreased by thesame rate instead of reducing the number of classes. Figure
2 shows the results. The solid lines represent the accuracy
when the number of classes was reduced and the dashedlines represent the results when the number of samples perclass was reduced. Results show that the number of classes
has a greater impact on the accuracy of few-shot learning
than the number of samples per class.
Next, we evaluated the performance of the proposed
method on miniImageNet when the number of classes in thetraining set for metric learning was increased by m (> 1)times the original number of classes. Figure 3 shows theresults. The accuracy of few-shot learning increases as thenumber of classes used in metric learning increases until
m = 3. By increasing the number of classes by 3 times, theaccuracy increases by 2.18 points from 50.39% to 52.57%
for 5-way 1-shot learning. However, the accuracy decreases

4. Conclusion
This paper proposed a few-shot learning approach thatuses an increased number of classes for the training data toperform metric learning. The approach was evaluated using
miniImageNet. Although the proposed method is relatively
simple, the method demonstrated good performance.

References[1] W. Li, L. Wang, J. Xu, J. Huo, Y. Gao, and J. Luo, “Revisiting Local Descriptor Based Image-To-Class Measure for FewShot Learning,” CVPR, 2019. 2[2] Y. Liu, J. Lee, M. Park, S. Kim, E. Yang, S. J. Hwang, and Y.
Yang, “Learning to Propagate Labels: Transductive Propagation Network for Few-shot Learning,” ICLR, 2019. 2[3] S. Gidaris and N. Komodakis, “Dynamic Few-Shot VisualLearning Without Forgetting,” CVPR, 2018. 2[4] S. Ravi and H. Larochelle, “Optimization as a Model for FewShot Learning,” ICLR, 2017. 1, 2
[5] C. Finn, P. Abbeel, and S. Levine, “Model-Agnostic MetaLearning for Fast Adaptation of Deep Networks,” ICML,
2017. 2[6] O. Vinyals, C. Blundell, T. Lillicrap, K. Kavukcuoglu, and D.
Wierstra, “Matching Networks for One Shot Learning,” NIPS,
2016. 1, 2
[7] H. Zhang, M. Cisse, Y. N. Dauphin, and D. Lopez-Paz,“mixup: Beyond Empirical Risk Minimization,” ICLR, 2018.
1