heavily relies on the massive-scale manually labeled training data, which is too expensive in many real scenarios. In contrast, humans are capable of learning new concepts with only a few examples, yet it still remains a challenge for modern machine learning systems. Hence, learning to generalize the knowledge in base classes (with sufficient annotated examples) to novel classes (with a few labeled examples), also known as few-shot learning, has attracted more and more attention[3, 19, 24, 7, 46, 42, 9, 36, 43, 35, 34, 10].
The one-shot and five-shot accuracy on novel classes (in red) and base classes (in blue) w.r.t different margins in cosine softmax loss on mini-ImageNet. As we expect, applying larger margin to softmax loss can achieve better accuracy on base classes. But surprisingly, applying appropriate negative margin to softmax loss can achieve state-of-the-art few-shot accuracy on novel classes.
An important direction of few-shot classification is meta learning, which aims to learn a meta-learner on base classes and generalizes it to novel classes. Metric learning based methods [3, 7, 24], are an important series of the meta-learning methods, and perform metric learning in the base classes and then transfer the learned metrics to the novel classes. For example, 
proved that simply using standard softmax loss or cosine softmax loss for learning metrics in base classes can achieve the state-of-the-art few-shot classification performance via learning a linear classifier on novel classes.
In the metric learning area, a common view is that the standard softmax loss is insufficient for discrimination on different training classes. Several previous approaches integrate the large and positive margin to the softmax loss  or the cosine softmax loss [6, 48]
so as to enforce the score of ground truth class larger than that of other classes by at least a margin. This could help to learn highly-discriminative deep features and result in remarkable performance improvement on visual recognition tasks, especially on face recognition[22, 6, 48].
Consequently, it inspires us to adopt this large-margin softmax loss to learn better metrics for few-shot classification. As we expected, shown as the blue curves in Fig. 1, the metrics learned by large-margin softmax with positive margin are more discriminative on training classes, resulting in higher few-shot accuracy on the validation set of training classes. But in the standard open-set setting of few-shot classification, shown as red curves in Fig. 1, we surprisingly find out that adding the positive margin in softmax loss would hurt the performance.
From our perspective, the positive margin would make the learned metrics more discriminative to training classes. But for novel classes, positive margin would map the samples of the same class to multiple peaks or clusters in base classes (shown in Fig. 3 and Fig. 7) and hurt their discriminability. We then give a theoretical analysis that the discriminability of the samples in the novel classes is monotonic decreasing w.r.t the margin parameter under proper assumption. Instead, appropriate negative margin could achieve a better tradeoff between the discriminability and transferability for novel classes, and achieves better performance on few-shot classification.
The main contributions of this paper are summarized as follows:
We provide insightful intuitive explanation and the theoretical analysis about why negative margin works well for few-shot classification.
The proposed approach with negative margin achieves state-of-the-art performance on three widely-used few-shot classification benchmarks.
2 Related Work
Few-Shot Classification. The existing representative few-shot learning methods can be broadly divided into three categories: gradient-based methods, hallucination-based methods, and metric-based methods.
Gradient-based methods tackle the few-shot classification by learning the task-agnostic knowledge. [9, 38, 30, 28, 26] focus on learning a suitable initialization of the model parameters which can quickly adapt to new tasks with a limited number of labeled data and a small number of gradient update steps. Another line of works aims at learning an optimizer, such as LSTM-based meta learner  and weight-update mechanism with an external memory 
, for replacing the stochastic gradient descent optimizer. However, it is challenging to solve the dual or bi-level optimization problem of these works, so their performance is not competitive on large datasets. Recently,[19, 1] alleviate the optimization problem by closed-form model like SVM, and achieve better performance on few-shot classification benchmark of large dataset.
Hallucination-based methods attempt to address the limited data issue by learning an image generator from base classes, which is adopted to hallucinate new images in novel classes [12, 49].  presents a way of hallucinating additional examples for novel classes by transferring modes of variation from base classes.  learns to hallucinate examples that are useful for classification by the end-to-end optimization of both classifier and hallucinator. As hallucination-based methods can be considered as the supplement and are always adopted with other few-shot methods, we follow  to exclude these methods in our experimental comparison and leave it to future work.
Metric-based methods aim at learning a transferable distance metric. MatchingNet 
computes cosine similarity between the embeddings of labeled images and unlabeled images, to classify the unlabeled images. ProtoNet represents each class by the mean embedding of the examples inside this class, and the classification is performed based on the distance to the mean embedding of each class. RelationNet  replaces the non-parametric distance in ProtoNet to a parametric relation module. Recently, [3, 7, 24]
reveal that the simple pre-training and fine-tuning pipeline (following the standard transfer learning paradigm) can achieve surprisingly competitive performance with the state-of-the-art few-shot classification methods.
Based on this simple paradigm, our work is the first endeavor towards explicitly integrating the margin parameter to the softmax loss, and mostly importantly breaks the inherent understanding that the margin can be only restricted as positive values, with both intuitive understanding and theoretical analysis. With an appropriate negative margin, our approach could achieve the state-of-the-art performance on three standard few-shot classification benchmarks.
Margin based Metric Learning. Metric learning aims to learn a distance metric between examples, and plays a critical role in many tasks, such as classification , clustering , retrieval  and visualization .
In practice, the margin between data points and the decision boundary plays a significant role in achieving strong generalization performance.  develops a margin theory and shows that the margin loss leads to an informative generalization bound for classification task. In the past decades, the idea of margin-based metric learning has been widely explored in SVM , k-NN classification , multi-task learning 
, etc. In the deep learning era, many margin-based metric learning methods are proposed to enhance the discriminative power of the learned deep features, and show remarkable performance improvements in many tasks[20, 19, 29], especially in face verification [40, 21, 48, 6]. For example, SphereFace , CosFace , and ArcFace 
enforce the intra-class variance and inter-class diversity by adding the margin to cosine softmax loss.
However, as the tasks of previous works are based on close-set scenarios, they limit the margin parameter as positive values [21, 48, 6], where making the deep features more discriminative could be generalized to the validation set and improve the performance. For open-set scenarios, such as few-shot learning, increasing the margin would not enforce the inter-class diversity but unfortunately enlarge the intra-class variance for novel classes, as shown in Fig. 2, which would hurt the performance. In contrast, an appropriate negative margin would better tradeoff the discriminability and transferability of deep features in novel classes, and obtain better performance for few-shot classification.
In a few-shot classification task, we are given two sets of data with different classes, formulated as as the base training set with base classes for the first training stage, and as the novel training set with novel classes for the second training stage. For the novel training set, each class has samples, where or , and is the standard setting [3, 19, 24, 7, 43, 35, 34]. This is called -way -shot learning. Few-shot classification aims to learn both discriminative and transferable feature representations from the abundant labeled data in base classes, such that the features can be easily adapted for the novel classes with few labeled examples.
3.1 Negative-margin Softmax Loss
In image classification, the softmax loss is built upon the feature representation of deep networks ( denotes the backbone network with the parameters ), its corresponding label
and the linear transform matrix. Recently, introducing the large and positive margin parameter to the softmax loss is widely explored in metric learning [22, 48, 6]. Hence, we directly integrate the margin parameter to the softmax loss to learn the transferable metrics, aiming at benefiting the few-shot classification on novel classes. The general formulation of large-margin softmax loss is defined as
where is the margin parameter, denotes the temperature parameter which could help to apply the appropriate concentrated level around the largest scores. And
denotes the similarity function between two input vectors.
It’s worth noting that all the previous works on large-margin softmax loss restrict the margin as positive values [22, 48, 6]. This is because that previous works focus on the close-set scenarios, the loss with larger margin leads to the smaller intra-class variance and the larger between-class variance, which will help to classify examples in the same classes. This is also validated in Figure 1, that the softmax loss with larger margin could improve the classification accuracy on the validation set of training classes.
However, the situations are different in the open-set scenarios. Learned metrics which are too discriminative to training classes may hurt their transferability to the novel classes. So applying appropriate negative margin to softmax loss aims to tradeoff the discriminability on training classes and the transferability to novel classes of the learned metrics.
Here we formulate two instantiations of Eqn. 1 with different similarity functions. By taking the inner-product similarity into Eqn. 1, the negative-margin softmax loss (abbreviated as Neg-Softmax) could be obtained. By taking the cosine similarity into Eqn. 1, we can formulate the negative-margin cosine softmax loss
(abbreviated as Neg-Cosine). The detailed loss functions could be found at the Appendix. These two loss functions are adopted at the pre-training stage, as shown in Figure5.
3.2 Discriminability analysis of deep features w.r.t different margins
We analyze the discriminability of the deep features extracted by the deep model with different margins, to understand why negative margin works well on novel classes. For simplicity, we only analyze the cosine softmax loss, and it is direct to extend the analysis and conclusion to standard softmax loss.
We denote the pre-trained backbone network trained with margin parameter as . For class in base classes or novel classes, denote the set of examples labeled with class as . We compute the class center for class as the mean of the L2-normalized feature embeddings as
The dataset with C classes could be base dataset with a large number of base classes or novel dataset with small number of novel classes (such as 5 for 5-way few shot learning). Then we define the inter-class variance , and intra-class variance as
For every two classes, the inter-class variance is the squared L2 distance between their class centers. For each class, the intra-class variance is the squared L2 distance between every sample in this class and the class center.
If inter-class variance becomes larger or intra-class variance becomes smaller, the deep features would be more discriminative. So we follow  to define the discriminative function as the inter-class variance divided by the intra-class variance:
To measure the discriminability of the deep features with different margins, we plot the inter-class variance , intra-class variance , and discriminative function w.r.t margin on both the base and novel classes of mini-ImageNet, respectively. As shown in Fig. 2, for base classes (red curves), as the margin increases, the inter-class variance increases a lot, meanwhile the intra-class variance does not change much, so the features of base classes become more discriminative. This is widely observed in previous works [6, 48, 22], and motivates them to introduce large and also positive margin to softmax loss for close-set scenarios.
But for novel classes (blue curves), the situation is just on the contrary. As the margin increases, the inter-class variance does not change much, but the intra-class variance increases a lot, so the features of base classes become less discriminative. This indicates that larger margin may hurt the classification on the novel classes. This is also verified in the real few-shot classification task, shown as red curves in Fig. 1, larger and positive margin will achieve worse performance of few-shot classification on novel classes. Instead, the appropriate negative margin could achieve the best performance, which may lead to a better tradeoff on discriminability and transferability for novel classes.
3.3 Intuitive Explanation
To better understand how the margin works, we perform the visualization on the data distributions in the angular space trained on MNIST111This technique is widely used to characterize the feature embedding under the softmax-related objectives [48, 21, 55]., as shown in Fig. 3. We choose seven classes as the base classes for pre-training, and adopt the other three classes as the novel classes. We first train this deep model with 2-dimensional output features using cosine softmax loss with different margins on the base classes. Then we normalize the 2-D features to obtain the direction of each data point, and visualize the count of each direction (also known as the data distributions in angular space) on both base (first row) and novel classes (second row) using the models trained with different margins.
As shown in the first row in Fig. 3, with larger and even positive margin (from left to right), the clusters for each training class are getting thinner and higher, and the angle differences between different class centers are getting larger. This matches our previous observation in Fig. 2, that enlarging the margin leads to the smaller intra-class variance and larger inter-class variance on the base classes.
However, with larger margin, less data points would lie in the space far from all centers, which to some extent makes the output space much narrower. As shown on the right side of the second row in Fig. 3, as novel classes are different to base classes, model with large margin may map the data points of the same class in novel classes to multiple peaks or clusters belonging to different base classes. Then the intra-class variance for novel classes would increase accordingly, making the classification of novel classes more difficult. Instead, as shown on the left side of second row in Fig. 3, the appropriate negative margin would not enforce the data points in novel classes too close to the training center, and may alleviate the multi-peak issue, which could benefit the classification on novel classes.
3.4 Theoretical Analysis
After giving the intuitive explanation that why negative margin works well on novel classes, we then prove this claim theoretically. Denote the parameter of the classifier joint pre-trained with backbone on base classes with margin as
, the probability of a sample in the novel categoryclassified by pre-trained backbone and classifier as a base category is
where denotes the similarity function. The probability of a pair of samples in the same novel category classified into the same base class is . And the average probability of is .
Proposition. Assuming discriminative function for the base classes is a monotonic increasing function w.r.t margin parameter , and then we denote , where and is a scale variable. is a monotonic decreasing function and we denote . , we have .
Proof. Since , substituting it into the , we have
The above proposition proves that the discriminative function on the novel classes is a monotonic decreasing function w.r.t under proper assumption and a measurable condition about the similarity between base and novel classes using . The proposition indicates that an appropriate value of “negative” margin could work well for discriminating the samples in novel classes.
Fig. 4 shows the actual behavior of mini-ImageNet dataset. We first sort the 36 novel classes according to the probability of sample pairs in the same novel class classified into the same base class (one of every 3 categories are plotted for clarity) on mini-ImageNet. And the histograms of the samples in novel classes to be classified to 64 base classes is shown in Fig. 4(a). Fig. 4(b) shows the accuracy curves w.r.t different margins for novel classes with different averaged . With smaller , the histograms of novel classes become more diverse (shown in Fig. 4(a)) and their accuracies become lower (shown in Fig. 4(b)). Importantly, most subsets of novel classes favor negative margins, implying the condition in the Proposition is not hard to reach.
Following the standard transfer learning paradigm [53, 8], we adopt a two-stage training pipeline for few-shot classification, as shown in Figure 5, including pre-training stage to perform metric learning on the abundant labeled data in base classes, and fine-tuning stage to learn a classifier to recognize novel classes. This pipeline is widely adopted in recent few-shot learning methods [3, 7, 24].
In the pre-training stage, we aim at training the backbone network with abundant labeled data in base classes, driven by metric learning loss, such as softmax loss in . In our paper, we adopt the negative-margin softmax loss, which could learn more transferable representations for few-shot learning. In the fine-tuning stage, as there are only few labeled samples in for training (e.g. 5-way 1-shot learning only contains 5 training samples), we follow  to fix the parameters of the backbone , and only train a new classifier from scratch by the softmax loss. Note that, the computation of similarity (such as inner-product similarity or cosine similarity) in softmax loss is the same as that in the pre-training stage.
Datasets and scenarios. Following , we address the few-shot classification problem under three different scenarios: (1) generic object recognition; (2) fine-grained image classification; and (3) cross-domain adaptation.
For the generic scenario, the widely-used few-shot classification benchmark: mini-ImageNet, is used to evaluate the effectiveness of the proposed Negative-Margin Softmax Loss. The mini-ImageNet dataset, firstly proposed by , consists of a subset of 100 classes from the ILSVRC-2012 , and contains 600 images for each classes. Following the commonly-used evaluation protocol of , we split the 100 classes into 64 base, 16 validation, and 20 novel classes for pre-training, validation, and testing.
For the fine-grained image classification, we use CUB-200-2011 dataset  (hereinafter referred as CUB), which consists of 200 classes and 11,788 images in total. Following the standard setting of , we split the classes in the dataset into 100 base classes, 50 validation classes, and 50 novel classes.
For the cross-domain adaptation scenario, we use mini-ImageNet CUB , in which the 100 classes in mini-ImageNet, the 50 validation and 50 novel classes in CUB are adopted as base, validation and novel classes respectively, to evaluate the performance of the proposed Negative-Margin Softmax Loss in the presence of domain shift.
Implementation details. For fair comparison, we evaluate our model with four commonly used backbone networks, namely Conv-4 , ResNet-12 , ResNet-18  and WRN-28-10 [24, 54]. Besides the differences in network depth and architecture, the expected input size of Conv-4 and ResNet-12 is 8484, and that of ResNet-18 is 224224, while WRN-28-10 takes 8080 images as input.
Our implementation is based on PyTorch
. In the training stage, the backbone network and classifier are trained from scratch, with a batch size of 256. The models are trained for 200, 400 and 400 epochs in the CUB, mini-ImageNet and mini-ImageNetCUB, respectively. We adopt the Adam  optimizer with initial learning rate 3e-3 and cosine learning rate decay . We apply the same data argumentation as , including random cropping, horizontal flipping and color jittering.
In the fine-tuning stage, each episode contains 5 classes and each class contains 1 or 5 support images to train a new classifier from scratch and 16 query images to test the accuracy. The final performance is reported as the mean classification accuracy over 600 random sampled episodes with the 95% confidence interval. Note that all the hyper-parameters are determined by the performance on the validation classes.
Results on mini-ImageNet. For the generic object recognition scenario, we evaluate our methods on the widely-used mini-ImageNet dataset. For fair comparison with existing methods which uses different network architecture as backbone, we evaluate our methods with all four commonly used backbone networks. The 5-way 1-shot and 5-shot classification results on the novel classes of the mini-ImageNet dataset are listed in Table 1. We find that by simply adopting appropriate negative margin in standard softmax loss, our Neg-Softmax achieves competitive results with the existing state-of-the-art methods. It is worth noting that our Neg-Cosine achieves the state-of-the-art performance for both 1-shot and 5-shot settings on almost all four backbones on mini-ImageNet.
|Backbone||Method||1 shot||5 shot|
|Conv-4||MAML ||48.70 1.84||63.11 0.92|
|ProtoNet ||49.42 0.78||68.20 0.66|
|MatchingNet ||48.14 0.78||63.48 0.66|
|RelationNet ||50.44 0.82||65.32 0.70|
|MAML+Meta-dropout ||51.93 0.67||67.42 0.52|
|R2D2 ||51.20 0.60||68.80 0.10|
|Neg-Softmax (ours)||47.65 0.78||67.27 0.66|
|Neg-Cosine (ours)||52.84 0.76||70.41 0.66|
|ResNet-12||SNAIL ||55.71 0.99||68.88 0.92|
|TADAM ||58.50 0.30||76.70 0.30|
|MetaOptNet-SVM ||62.64 0.61||78.63 0.46|
|Neg-Softmax (ours)||62.58 0.82||80.43 0.56|
|Neg-Cosine (ours)||63.85 0.81||81.57 0.56|
|ResNet-18||SNCA ||57.80 0.80||72.80 0.70|
|Baseline ||51.75 0.80||74.27 0.63|
|Baseline++ ||51.87 0.77||75.68 0.63|
|Neg-Softmax (ours)||59.02 0.81||78.80 0.61|
|Neg-Cosine (ours)||62.33 0.82||80.94 0.59|
|WRN-28-10||Activation to Parameter ||59.60 0.41||73.74 0.19|
|LEO ||61.76 0.08||77.59 0.12|
|Fine-tuning ||57.73 0.62||78.17 0.49|
|Cosine + rotation ||62.93 0.45||79.87 0.33|
|Neg-Softmax (ours)||60.04 0.79||80.90 0.60|
|Neg-Cosine (ours)||61.72 0.81||81.79 0.55|
Results on CUB. On the fine-grained dataset CUB, we compared the proposed method with several state-of-the-art methods with ResNet-18 as backbone. The results are showed in Table 2, in which the results of the comparison methods are directly borrowed from . It shows that the proposed Neg-Cosine outperforms all the comparison methods on both 1-shot and 5-shot settings. Furthermore, Neg-Softmax also achieves highly competitive performance on both 1-shot and 5-shot settings.
Results on mini-ImageNet CUB. In the real-world applications, there may be a signification domain shift between the base and novel classes. So we evaluate our methods on a cross domain scenario: mini-ImageNet CUB, where we pre-train the backbone on a generic object recognition dataset, and transfer it to a fine-grained dataset. We follow  to report the 5-shot results with ResNet-18 backbone, as shown in Table 2. We can observe that both Neg-Softmax and Neg-Cosine are significantly better than all the comparison methods. Specifically, Neg-Softmax outperforms Baseline , the state-of-the-art method on the mini-ImageNet CUB, by a large margin of .
This section presents a comprehensive analysis of the proposed approach. In the following experiments, we use Neg-Cosine with ResNet-18 backbone as default.
Effects of negative margin. Table 3 shows the 1-shot and 5-shot accuracy of the standard softmax, cosine softmax and our proposed Neg-Softmax, Neg-Cosine on the validation classes of mini-ImageNet, CUB and mini-ImageNet CUB. By adopting appropriate negative margin, Neg-Softmax and Neg-Cosine yields significant performance gains over standard softmax loss and cosine softmax loss on all three benchmarks. Interestingly, Neg-Cosine outperforms Neg-Softmax in the in-domain setting, such as mini-ImageNet and CUB, while Neg-Softmax could achieve better performance than Neg-Cosine in the cross-domain setting. This is also observed in .
|1 shot||5 shot||5 shot|
|MAML ||69.96 1.01||82.70 0.65||51.34 0.72|
|ProtoNet ||71.88 0.91||87.42 0.48||62.02 0.70|
|MatchingNet ||72.36 0.90||83.64 0.60||53.07 0.74|
|RelationNet ||67.59 1.02||82.75 0.58||57.71 0.73|
|Baseline ||65.51 0.87||82.85 0.55||65.57 0.70|
|Baseline++ ||67.02 0.90||83.58 0.54||62.04 0.76|
|Neg-Softmax (ours)||71.48 0.83||87.30 0.48||69.30 0.73|
|Neg-Cosine (ours)||72.66 0.85||89.40 0.43||67.03 0.76|
|1 shot||5 shot||1 shot||5 shot||1 shot||5 shot|
Accuracy w.r.t different margins. Figure 6 shows the 1-shot accuracy and 5-shot accuracy on validation classes of mini-ImageNet dataset w.r.t different margins in Neg-Cosine and Neg-Softmax. As we expect, as the margin gets negative and smaller, both the 1-shot accuracy and 5-shot accuracy of Neg-Cosine and Neg-Softmax first increase and then decrease, demonstrating a desirable bell-shaped curve. Hence, adopting appropriate negative margin yields significant performance gains over both standard softmax loss and cosine softmax loss on 1-shot and 5-shot classification of mini-ImageNet.
|1 shot||5 shot|
|54.51 0.79||75.70 0.62|
|✓||60.25 0.81||80.07 0.58|
|✓||✓||62.21 0.83||80.81 0.59|
|✓||✓||✓||62.33 0.82||80.94 0.59|
Various regularization techniques. Table 4 shows the importance of regularizations on Neg-Cosine, which reveals that integrating various regularization techniques steadily improves the 1-shot and 5-shot test accuracy on mini-ImageNet benchmark. Firstly, by simply adopting negative margin, the test accuracy increased by 5.74% and 4.37% on the 1-shot and 5-shot settings, respectively. Based on our approach, weight decay and DropBlock could further improve the performance. After integrating all regularizations together, our method achieves state-of-the-art accuracy of and for the 1-shot and 5-shot settings respectively on novel classes of mini-ImageNet.
T-SNE visualization. Fig. 7 shows the t-SNE  visualizations of the feature embedding and the corresponding 1-shot accuracy in the base and novel classes of mini-ImageNet dataset for negative, zero and positive margin respectively. As shown in the first row in Fig. 7, compared with negative margin, the feature embedding of zero and positive margin exhibit more discriminative structures and achieve better 1-shot accuracy on the base classes. However, the second row in Figure 7 shows that enlarging the margin parameter would break the cluster structure of the novel classes and make the classification of novel classes harder. Instead, the appropriate negative margin could tradeoff the discriminability and transferability of deep features in the novel classes, and retain the better cluster structure for novel classes. Thus the few-shot classification accuracy of negative margin is better than that of zero and positive margin.
More shots. We conduct an experiment by varying the number of shots from 1 (few shot) to 300 (many shot) and report the classification accuracy of the validation classes on the mini-ImageNet dataset in Figure 8. It shows that the test accuracy of margin= is consistently higher than that of margin= from 1-shot to 300-shot settings, which prove that the negative margin could benefit the open-set scenarios with more shots. But there is another trend we cannot ignore, the gap between margin= and margin= is getting smaller when the number of shots increase. In other words, when sufficient data is available in the novel classes, the influence of the metrics learned from the base classes to the novel classes is weakened.
In this paper, we unconventionally propose to adopt appropriate negative-margin to softmax loss for few-shot classification, which surprisingly works well for the open-set scenarios of few-shot classification. We then provide the intuitive explanation and the theoretical proof to understand why negative margin works well for few-shot classification. This claim is also demonstrated via sufficient experiments. With the negative-margin softmax loss, our approach achieves the state-of-the-art performance on all three standard benchmarks of few-shot classification. In the future, the negative margin may be applied in more general open-set scenarios that do not restrict the number of samples in novel classes.
Appendix 0.A Instantiations of Negative-Margin Loss
Eqn. 1 provides a general formulation for the margin softmax loss. Here, we provide detailed formulation of the two instantiations: negative-margin softmax loss and negative-margin cosine softmax loss as:
where is the margin parameter. Note that the formulations are the same as the large-margin softmax loss in  and the large-margin cosine loss in , but we restrict the margin as a non-positive value () while the original formulations restrict the margin as a non-negative value ().
We follow the pre-training and fine-tuning pipeline introduced in Sec. 3.5, and the proposed negative-margin (cosine) softmax loss is applied in the pre-training stage, as illustrated in Figure 5. Note we do not apply the negative-margin loss to the pre-training stage, where we find regular (cosine) softmax loss (margin ) performs well, as detailed in the following section.
Appendix 0.B The effects of margin in the fine-tuning stage
In the main part of the paper, we show that applying the negative-margin softmax loss into the pre-training stage leads to better discrimination of novel classes. In this section, we investigate the effects of the margin parameter on the fine-tuning stage. As shown in Fig. 9, the 5-shot classification accuracy in the validation classes is insensitive when varying margin values, while that of 1-shot classification increases marginally when increasing margin values. Such behavior is different from the effects of the margin parameter in the pre-training stage, indicating that the negative margin mainly effects in open-set scenarios. Also note the accuracy is much more insensitive w.r.t margin parameter than that of pre-training and fine-tuning both using base classes (the blue curves in Fig 1), probably because the feature is fixed in the fine-tuning stage and different margin values can all find good discrimination planes well.
Appendix 0.C Relationship between negative margin and label smoothing
The same as negative margin loss, the label smoothing  technique also aims at facilitating the difficulty of equalising softmax outputs and the binary ground-truth labels. Technically, while the label smoothing technique changes the ground truth target labels from binary values to soft ones which alleviate the equalising of softmax outputs and the binary ground-truth labels, the negative margin loss modify the other side of softmax outputs. Although resulting in similarly smaller loss than regular training, they perform very differently on training classes and novel classes.
In softmax based image classification, the final prediction is the class with the largest softmax probability and the accuracy is 100% if all predictions match the ground truth label. The softmax output for the ground truth label is not necessarily as 1, but is correct as long as it is larger than the softmax outputs of other classes. In another word, the cross entropy loss which encourages the softmax output of the right class to be exactly 1 is stricter than the real target of doing right classification. The label smoothing technique relaxes the ground-truth labels as soft ones, which shrinks the gap between cross-entropy loss and the real classification target. As a result, it usually achieves higher accuracy on the validation images of training classes, indicating better discrimination of training classes. On the contrary, the negative margin technique enlarges the gap between loss and real classification accuracy. It usually results in lower accuracy on the validation images of training classes, indicating lower discrimination of training classes.
Table 5 investigate the effects of two techniques by applying few-shot fine-tuning on either validation images (ILSVRC-2012 images of the base classes but not in mini-ImageNet) of base classes or images of val classes. For label smoothing, is set as 0.05. For negative margin, . It can be seen that the label smoothing technique improves the performance on the base classes by 3.48% and 0.21% for the 1-shot and 5-shot setting respectively, but has 1.47% and 3.03% accuracy drop on the validation classes for the 1-shot and 5-shot settings, respectively. On the contrary, the negative margin technique has lower performance on the validation images of training classes but benefits both the 1-shot and 5-shot classification accuracy on the validation classes.
These results are in accord with the previous analysis that the different effects of the negative margin technique and the label smoothing technique. While the label smoothing technique tends to improve the discriminability of base classes and harm the transferability to novel classes, the negative margin technique has lower discriminability of base classes but can improve the feature transferability to novel classes.
|Smoothing||Margin||1 shot||5 shot||1 shot||5 shot|
|85.45 0.67||93.72 0.31||59.49 0.90||78.90 0.61|
|✓||88.93 0.62||93.93 0.30||58.02 0.97||75.87 0.71|
|✓||79.92 0.81||92.34 0.38||63.68 0.86||81.60 0.56|
-  (2019) Meta-learning with differentiable closed-form solvers. In International Conference on Learning Representations, External Links: Cited by: §2, Table 1.
-  (2017) Quo vadis, action recognition? a new model and the kinetics dataset. In , pp. 6299–6308. Cited by: §1.
-  (2019) A closer look at few-shot classification. In International Conference on Learning Representations, Cited by: §1, §1, §2, §2, §3.5, §3.5, §3, §4.1, §4.1, §4.1, §4.1, §4.2, §4.2, §4.3, Table 1, Table 2.
-  (2017) Deformable convolutional networks. In Proceedings of the IEEE International Conference on Computer Vision, pp. 764–773. Cited by: §1.
-  (2009) Imagenet: a large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Cited by: §4.1.
-  (2019) Arcface: additive angular margin loss for deep face recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4690–4699. Cited by: item 1, §1, §2, §2, §3.1, §3.1, §3.2.
-  (2019) A baseline for few-shot image classification. arXiv preprint arXiv:1909.02729. Cited by: §1, §1, §2, §3.5, §3, Table 1.
-  (2014) Decaf: a deep convolutional activation feature for generic visual recognition. In International conference on machine learning, pp. 647–655. Cited by: §3.5.
-  (2017) Model-agnostic meta-learning for fast adaptation of deep networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1126–1135. Cited by: §1, §2, Table 1, Table 2.
Few-shot learning with graph neural networks. arXiv preprint arXiv:1711.04043. Cited by: §1.
-  (2019) Boosting few-shot visual learning with self-supervision. arXiv preprint arXiv:1906.05186. Cited by: Table 1.
-  (2017) Low-shot visual recognition by shrinking and hallucinating features. In Proceedings of the IEEE International Conference on Computer Vision, pp. 3018–3027. Cited by: §2.
-  (2015) Deep residual learning for image recognition. arXiv preprint arXiv:1512.03385. Cited by: §1.
-  (2018) Few-shot learning with metric-agnostic conditional embeddings. arXiv preprint arXiv:1802.04376. Cited by: §4.1.
-  (2014) Adam: a method for stochastic optimization. arXiv preprint arXiv:1412.6980. Cited by: §4.1.
-  (2002) Empirical margin distributions and bounding the generalization error of combined classifiers. The Annals of Statistics 30 (1), pp. 1–50. Cited by: §2.
Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pp. 1097–1105. Cited by: §1.
-  (2020) Meta dropout: learning to perturb latent features for generalization. In International Conference on Learning Representations, External Links: Cited by: Table 1.
-  (2019) Meta-learning with differentiable convex optimization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 10657–10665. Cited by: §1, §2, §2, §3, Table 1.
-  (2018) Deep triplet quantization. 2018 ACM Multimedia Conference on Multimedia Conference - MM ’18. External Links: Cited by: §2, §2.
-  (2017) Sphereface: deep hypersphere embedding for face recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 212–220. Cited by: §2, §2, footnote 1.
-  (2016) Large-margin softmax loss for convolutional neural networks. arXiv preprint arXiv:1612.02295. Cited by: Appendix 0.A, item 1, §1, §3.1, §3.1, §3.2.
-  (2016) Sgdr: stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983. Cited by: §4.1.
-  (2019) Charting the right manifold: manifold mixup for few-shot learning. arXiv preprint arXiv:1907.12087. Cited by: §1, §1, §2, §3.5, §3, §4.1.
-  (1999) Fisher discriminant analysis with kernels. In Neural networks for signal processing IX: Proceedings of the 1999 IEEE signal processing society workshop (cat. no. 98th8468), pp. 41–48. Cited by: §3.2.
-  (2018) A simple neural attentive meta-learner. In International Conference on Learning Representations, External Links: Cited by: §2, Table 1.
-  (2017) Meta networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 2554–2563. Cited by: §2.
Rapid adaptation with conditionally shifted neurons. In ICML, pp. 3661–3670. Cited by: §2.
-  (2019) Designing an effective metric learning pipeline for speaker diarization. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 5806–5810. Cited by: §2.
-  (2018) On first-order meta-learning algorithms. arXiv preprint arXiv:1803.02999. Cited by: §2.
-  (2018) Tadam: task dependent adaptive metric for improved few-shot learning. In Advances in Neural Information Processing Systems, pp. 721–731. Cited by: §4.1, Table 1.
-  (2010) Large margin multi-task metric learning. In Advances in neural information processing systems, pp. 1867–1875. Cited by: §2.
-  (2017) Automatic differentiation in PyTorch. In NIPS Autodiff Workshop, Cited by: §4.1.
-  (2018) Low-shot learning with imprinted weights. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5822–5830. Cited by: §1, §3.
-  (2018) Few-shot image recognition by predicting parameters from activations. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 7229–7238. Cited by: §1, §3, Table 1.
-  (2016) Optimization as a model for few-shot learning. External Links: Cited by: §1, §2, §4.1.
-  (2015) Faster r-cnn: towards real-time object detection with region proposal networks. In Advances in neural information processing systems, pp. 91–99. Cited by: §1.
-  (2019) Meta-learning with latent embedding optimization. In International Conference on Learning Representations, External Links: Cited by: §2, Table 1.
Learning with kernels: support vector machines, regularization, optimization, and beyond. MIT press. Cited by: §2.
-  (2015) Facenet: a unified embedding for face recognition and clustering. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 815–823. Cited by: §2.
-  (2014) Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556. Cited by: §1.
-  (2017) Prototypical networks for few-shot learning. In Advances in Neural Information Processing Systems, pp. 4077–4087. Cited by: §1, §2, Table 1, Table 2.
-  (2018) Learning to compare: relation network for few-shot learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1199–1208. Cited by: §1, §2, §3, Table 1, Table 2.
-  (2016) Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826. Cited by: Appendix 0.C.
Visualizing high-dimensional data using t-sne. JMLR. Cited by: §2, §4.3.
-  (2016) Matching networks for one shot learning. In Advances in neural information processing systems, pp. 3630–3638. Cited by: §1, §2, §4.1, §4.1, Table 1, Table 2.
-  (2011) The Caltech-UCSD Birds-200-2011 Dataset. Technical report Technical Report CNS-TR-2011-001, California Institute of Technology. Cited by: §4.1.
-  (2018) Cosface: large margin cosine loss for deep face recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5265–5274. Cited by: Appendix 0.A, item 1, §1, §2, §2, §3.1, §3.1, §3.2, footnote 1.
-  (2018) Low-shot learning from imaginary data. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 7278–7286. Cited by: §2.
-  (2009) Distance metric learning for large margin nearest neighbor classification. Journal of Machine Learning Research 10 (Feb), pp. 207–244. Cited by: §2, §2.
-  (2018) Improving generalization via scalable neighborhood component analysis. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 685–701. Cited by: Table 1.
-  (2003) Distance metric learning with application to clustering with side-information. In Advances in neural information processing systems, pp. 521–528. Cited by: §2.
-  (2014) How transferable are features in deep neural networks?. In Advances in neural information processing systems, pp. 3320–3328. Cited by: §3.5.
-  (2016) Wide residual networks. Procedings of the British Machine Vision Conference 2016. External Links: Cited by: §4.1.
-  (2018) Ring loss: convex feature normalization for face recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5089–5097. Cited by: footnote 1.