# Loss Architecture Search for Few-Shot Object Recognition

Authors: Jun Yue; Zelang Miao; Yueguang He; Nianchun Du
Journal: Complexity
 (2020)

---

## Abstract

Few-shot object recognition, which exploits a set of well-labeled data to build a classifier for new classes that have only several samples per class, has received extensive attention from the machine learning community. In this paper, we investigate the problem of designing an optimal loss function for few-shot object recognition and propose a novel few-shot object recognition system that includes the following three steps: (1) generate a loss function architecture using a recurrent neural network (generator); (2) train a base embedding network with the generated loss function on a training set; (3) fine-tune the base embedding network using the few-shot instances from a validation set to obtain the accuracy and use it as a reward signal to update the generator. This procedure is repeated and implemented in the reinforcement learning framework for finding the best loss architecture such that the embedding network yields the highest validation accuracy. Our key insight is to create a search space of the loss function architectures and evaluate the quality of a particular loss function on the dataset of interest. We conduct experiments on three popular datasets for few-shot learning. The results show that the proposed approach achieves better performance than state-of-the-art methods.


---

## Body

## 1. Introduction

The object recognition problem under conventional supervised learning has been thoroughly studied with many successful models available, especially deep convolutional neural networks (DCNNs), including VGG [1], GoogLeNet [2], ResNet [3], and NASNet [4]. DCNNs can achieve impressive performance on large datasets like ImageNet [5] and Open Images [6]. However, in order to train a DCNN model, large amounts of labeled training data and training time are typically needed. Some works use pretrained DCNNs as off-the-shelf deep feature extractors [7]. While this procedure can reduce training time, it still requires lots of labeled images to fine-tune the models. This is in contrast with how a human vision recognition system works: a person does not need to see thousands of instances of an object, but only a small number of them, to remember and generalize for the recognition of the object later [8].Motivated by the high capability of human vision recognition system, one-/few-shot learning has attracted considerable attention from the computer vision community, including those on one-shot or few-shot learning for object recognition [9–14], object detection [15], image segmentation [16], image captioning [17], face identification [18], and person reidentification [19]. Different from the standard supervised learning, few-shot learning aims to solve the problem where only a few labeled samples are available for training, while its extreme scenario, called one-shot learning, handles the more challenging situation where only one instance per class is available. As training a classifier using only one or a few instances per class is difficult to achieve a desired result, studies on one-/few-shot object recognition have focused on training it with a set of well-labeled data and then generalizing it to new classes [10, 20].For one-/few-shot object recognition, due to the scarcity of the labeled examples from each new class, a natural metric learning scheme is adopted in [21], which aims to learn object representation and categorize instances based on the absolute similarities between pairs of instances. This absolute similarity-based method, however, does not pay enough attention to the interclass and intraclass correlation, which may not result in a satisfactory accuracy.Instead of absolute similarity, the scheme of relative similarity-based classification can have higher capability in decreasing the intraclass variations and increasing the interclass variations [22]. While it is difficult to separate or group objects only based on an absolute similarity measure, relative similarities can conveniently deal with these variations by requiring the intraclass similarity to be larger than the interclass similarity. Figure 1 shows an example of the advantage of relative similarity. There have been many metric learning methods based on relative similarity [23–26]. However, different metric learning losses can lead to different performances and there has been no rule of thumb to design the best loss for a dataset.Figure 1
An example that shows the advantage of relative similarity. Left: nine objects from three different classes. The lemons and oranges are similar in appearance. Middle: a pairwise similarity-based model may be confused by a pair of objects from the lemon and orange classes. Right: if a model learns relative similarity between objects, it may not be confused since the anchor object (in the blue box) is relatively similar to the lemon compared to the orange.
(a)(b)(c)Hence, in this paper, we develop a novel object representation-based metric learning method that induces suitable relative similarities with a particular loss generated by loss architecture search (LAS), inspired by the neural architecture search (NAS) [4, 27]. LAS, as shown in Figure 2, is a gradient-based method for finding good loss architectures. We use a recurrent neural network as the loss function architecture generator to generate a suitable loss for training the embedding network. The generator is updated with a reward signal, which measures how good the metric learning loss is based on the relative similarity. To obtain the reward signal, the following two steps are carried out. First, we train the embedding network with the generated loss L using the training set. Second, we use the few-shot instances from the validation set to fine-tune the embedding network to obtain the accuracy R. With this accuracy as the reward signal, we can compute the policy gradient (i.e., the gradient of P) by proximal policy optimization (PPO) [28] to update the loss generator. As a result, in the next iteration, the generator gives higher probabilities to those losses that drive the embedding network to obtain higher accuracies. In other words, the generator learns to improve its search over time. After obtaining the final loss function L∗ with the highest validation accuracy, the few-shot object recognition system is completed by updating the embedding network with the training set and the testing set (see the right part of Figure 2).Figure 2
Overview of the proposed loss architecture search (LAS) for few-shot object recognition.The proposed approach trains the object embedding network on the well-labeled training set under a loss function generated by LAS, such that the instances from new classes can be categorized based on their similarities with the few-shot instances in the learned embedding space. Our main contributions are threefold:(1)
We create a search space for automatically determining the hyperparameters of metric learning losses, including their magnitudes, margins, and angle(2)
We present a few-shot recognition system where a proximal policy optimization algorithm is used to find the best loss architecture sampled from the search space such that the embedding network yields the highest validation accuracy(3)
Our few-shot object recognition system with LAS by reinforcement learning obtains the best results compared with recent state-of-the-art methods


## 2. Related Work

### 2.1. Few-Shot Learning

Recent works for few-shot learning have adopted different strategies in different domains [8, 9, 11, 18, 21, 29–33], among which the most relevant ones are the metric learning-based methods [8, 21]. The Siamese network developed in [21] aims to learn absolute similarity between pairs of objects. It enlarges or lessens the similarity between a pair of samples according to whether they are from the same class. The authors of [8] propose a matching network which can also be considered as a metric learning-based method. This approach minimizes the cosine distance based-Siamese loss between the embeddings of instances with a bidirectional Long Short-Term Memory (bi-LSTM). Another line of research uses metalearning for few-shot learning, which trains a metalearner from many relevant tasks. In [29], model agnostic metalearning is proposed to train a model that can quickly adapt to a new task with limited training data. The authors of [9] propose an LSTM-based metalearner model to train another learner in the few-shot regime. Another metalearning-based method is proposed in [30] which learns to fast parameterize an underlying neural network by employing metainformation. The memory-augmented neural network is adopted in [31] for few-shot learning. It enables each instance to be encoded and retrieved efficiently by a memory module. This module consists of key-value pairs where keys and values are the embeddings and labels of examples, respectively. Another work from [32] also uses a memory module for training, with a bi-LSTM to predict the parameters of the embedding model. The authors of [33] propose a task agnostic approach to improve the generalizability of few-shot metalearning. In addition to the research mentioned above, a few other works generate synthetic data for learning [11, 18]. Different from these previous methods, we design our few-shot object recognition system in the reinforcement learning framework, which automatically determines the optimal loss function for training the embedding network.


### 2.2. MetricLearning

Metric learning aims to learn a similarity function from examples, which measures the similarity between object pairs. Recently, quite a few methods have been proposed for metric learning. Some works [34–36] adopt pairwise constraints to train the models. As discussed in Section 1, these models’ capacity is limited due to the use of absolute similarity. Most recent works [23, 26, 37] use DCNNs as embedding functions and use triplet-based constraints instead of pairwise constraints to capture similarities between objects. Their results show that the combination of a deep embedding model with a triplet-based constraint is effective in learning similarity functions. Nevertheless, the problems solved in these works still fall into the conventional supervised learning setting where a set of well-labeled data are needed. In our work, instead of manually designing a metric learning loss and training with a large amount of labeled data, we use LAS for metric learning, which can automatically determine the hyperparameters of relative similarity-based losses such as margin, magnitude, and angle.


### 2.3. AutoML

The success of deep learning in computer vision tasks is largely due to its automation of the feature extraction process; hierarchical feature extractors are learned in an end-to-end fashion from data rather than being manually designed. To obtain better performance and handle more difficult problems, researchers have manually developed more and more complex networks. To automate the design of network architectures, neural architecture search [4, 27] is thus a logical next step in machine learning. NAS can be seen as a subfield of AutoML. The work form [38] proposed a method to automatically determine the parameters of softmax-based loss architecture by using AutoML. In our work, we propose LAS for finding the best architecture of the metric learning-based loss function for few-shot learning, which can be seen as another subfield of AutoML. We believe that combining NAS and LAS will make AutoML go further and this is the future work.


## 2.1. Few-Shot Learning

Recent works for few-shot learning have adopted different strategies in different domains [8, 9, 11, 18, 21, 29–33], among which the most relevant ones are the metric learning-based methods [8, 21]. The Siamese network developed in [21] aims to learn absolute similarity between pairs of objects. It enlarges or lessens the similarity between a pair of samples according to whether they are from the same class. The authors of [8] propose a matching network which can also be considered as a metric learning-based method. This approach minimizes the cosine distance based-Siamese loss between the embeddings of instances with a bidirectional Long Short-Term Memory (bi-LSTM). Another line of research uses metalearning for few-shot learning, which trains a metalearner from many relevant tasks. In [29], model agnostic metalearning is proposed to train a model that can quickly adapt to a new task with limited training data. The authors of [9] propose an LSTM-based metalearner model to train another learner in the few-shot regime. Another metalearning-based method is proposed in [30] which learns to fast parameterize an underlying neural network by employing metainformation. The memory-augmented neural network is adopted in [31] for few-shot learning. It enables each instance to be encoded and retrieved efficiently by a memory module. This module consists of key-value pairs where keys and values are the embeddings and labels of examples, respectively. Another work from [32] also uses a memory module for training, with a bi-LSTM to predict the parameters of the embedding model. The authors of [33] propose a task agnostic approach to improve the generalizability of few-shot metalearning. In addition to the research mentioned above, a few other works generate synthetic data for learning [11, 18]. Different from these previous methods, we design our few-shot object recognition system in the reinforcement learning framework, which automatically determines the optimal loss function for training the embedding network.


## 2.2. MetricLearning

Metric learning aims to learn a similarity function from examples, which measures the similarity between object pairs. Recently, quite a few methods have been proposed for metric learning. Some works [34–36] adopt pairwise constraints to train the models. As discussed in Section 1, these models’ capacity is limited due to the use of absolute similarity. Most recent works [23, 26, 37] use DCNNs as embedding functions and use triplet-based constraints instead of pairwise constraints to capture similarities between objects. Their results show that the combination of a deep embedding model with a triplet-based constraint is effective in learning similarity functions. Nevertheless, the problems solved in these works still fall into the conventional supervised learning setting where a set of well-labeled data are needed. In our work, instead of manually designing a metric learning loss and training with a large amount of labeled data, we use LAS for metric learning, which can automatically determine the hyperparameters of relative similarity-based losses such as margin, magnitude, and angle.


## 2.3. AutoML

The success of deep learning in computer vision tasks is largely due to its automation of the feature extraction process; hierarchical feature extractors are learned in an end-to-end fashion from data rather than being manually designed. To obtain better performance and handle more difficult problems, researchers have manually developed more and more complex networks. To automate the design of network architectures, neural architecture search [4, 27] is thus a logical next step in machine learning. NAS can be seen as a subfield of AutoML. The work form [38] proposed a method to automatically determine the parameters of softmax-based loss architecture by using AutoML. In our work, we propose LAS for finding the best architecture of the metric learning-based loss function for few-shot learning, which can be seen as another subfield of AutoML. We believe that combining NAS and LAS will make AutoML go further and this is the future work.


## 3. Loss Architecture Search

We formulate the problem of finding the best loss architecture as a discrete search problem. In our search space, a loss architecture consists of five subloss architectures, each of which has two hyperparameters: (1) the magnitude of the operation and (2) the margin or angle of the subloss.


### 3.1. Losses

We choose five promising losses to construct the search space: Hard Mining Triplet Loss (HMTL) [23], Margin Sample Mining Loss (MSML) [24], Angular Loss (AL) [25], Triplet Center Loss (TCL) [26], and Quadruplet Center Loss (QCL). The first four are from the metric learning community, which achieve state-of-the-art results in few-shot learning, face recognition, vehicle Re-ID, person Re-ID, and so forth. The last one, QCL, is proposed in this paper and is a complement to the first four losses.


#### 3.1.1. Hard Mining Triplet Loss

The triplet loss is based on a relative distance comparison among triplet instances. Specifically, for any tripletxai,xpi,xni where xai and xpi are two distinct samples of the same class and xni comes from another class as a negative example, their embedding vectors are generated by an embedding function fϕ such that hai=fϕxai, hpi=fϕxpi, and hni = fϕxni. The relative distance constraint of each triplet is defined as(1)Dhai,hpi+m≤Dhai,hni,where m is a predefined constant parameter representing the minimum margin between the matched and mismatched pairs, Dx,y is a metric function that measures distance between vectors x and y, and i denotes the i-th triplet. In order to ensure fast convergence, it is crucial to select triplets that violate the triplet constraint in equation (1). This means that, given xai, we want to select an xpi (hard positive sample) such that xpi=argmaxxpDfϕxai,fϕxp and to select xni (hard negative sample) such that xni=argminxnDfϕxai,fϕxn. For each sample (as an anchor) from a batch of size M, we select a hard-positive sample and a hard-negative sample (also from the batch) to construct a triplet. Thus, the HTML function can be defined as(2)LHMTL=1M∑i=1Mmax0,m+Dhai,hpi−Dhai,hni.


#### 3.1.2. Margin Sample Mining Loss

The quadruplet loss (QL) [22] extends the triplet loss by adding a different negative pair1. A quadruplet contains four different instances xai,xpi,xn1i,xn2i, where xai and xpi are samples of the same class, while xn1i and xn2i are samples of two other classes. The quadruplet loss is formulated as(3)LQL=1NQL∑i=1NQLmax0,m1+Dhai,hpi−Dhai,hn1i+1NQL∑i=1NQLmax0,m2+Dhai,hpi−Dhn1i,hn2i,where m1 and m2 are two margins for the two terms, respectively, and NQL stands for the number of quadruplets. The first term is the same as the triplet loss. The second term tries to enforce intraclass distances to be smaller than interclass distances [22]. Based on QL, a strategy named margin sample mining is proposed [24]. It picks the most dissimilar positive pair xa,xp and the most similar negative pair xn1,xn1 in the whole batch and formulates its loss as(4)LMSML=max0,m+Dfϕxa,fϕxp−Dfϕxn1,fϕxn1.As shown in equation (4), the constraints of MSML are extremely sparse. Only two pairs in a batch are used to compute the gradient of the embedding network in the training phase, and it seems that it wastes a lot of training data. In fact, the two chosen pairs are determined by all the data in one batch. During training, more and more pairs will be selected [24].


#### 3.1.3. Angular Loss

Let a tripletxai,xpi,xni form a triangle △xaixpixni whose sides are denoted as sap, san, and spn. The original triplet constraint equation (1) enforces that san is longer than sap. Because the anchor and positive samples are of the same class, a symmetrical triplet constraint can be derived, which enforces Dhai,hpi+m≤Dhpi,hni. According to the cosine formula, it can be proved that the angle ∠xaixnixpi surrounded by the longer edges san and spn has to be the smallest one; that is, ∠xaixnixpi≤min∠xnixaixpi,∠xaixpixni. Furthermore, because ∠xaixnixpi+∠xnixaixpi+∠xaixpixni=180°, ∠xaixnixpi has to be less than 60°, which can be used to constrain the upper bound ∠xaixnixpi for each triplet triangle [25]:(5)∠xaixnixpi≤α,where α is a predefined parameter. However, a straightforward implementation of equation (5) becomes unstable in some special cases [25]. In order to solve this problem, the angular loss function is defined in the following equation:(6)LAL=1NAL∑i=1NALmax0,Dhai,hpi−4Dhni,hai+hpi2tan2α,where NAL is the number of triplets, which is also equal to the batch size M in our implementation.


#### 3.1.4. Triplet Center Loss

The goal of TCL is to leverage the advantages of the triplet loss and the center loss [39], that is, to effectively decrease the intraclass distances and increase the interclass distances simultaneously. Let a given training batch xi,yii=1M consist of M samples xi with the associated labels yi. In TCL, it is assumed that the features of each class share one center. Thus, the TCL is defined as(7)LTCL=1M∑i=1Mmax0,m+Dhai,cyi−Dhai,cn,where cyi is the center of class yi and cn is the negative center nearest to cyi.


#### 3.1.5. Quadruplet Center Loss

In equation (7), TCL aims to make the distance between the anchor and its corresponding center cyi smaller than the distance between the anchor and its nearest negative center cn. For example, in Figure 3(a), the anchor can be pushed to its center. However, in some cases such as the one in Figure 3(b), it cannot, even though it is still far away from its center. In order to solve this problem, we propose a quadruplet center loss:(8)LQCL=1M∑i=1Mmax0,m+Dhai,cyi−minc1,c2Dc1,c2,where c1,c2 is a pair of centers. Thus, the proposed loss function guarantees that an anchor that is not close enough to its center will be moved closer, while an anchor that is already close enough to its center will be neglected.Figure 3
Two cases in TCL. Minimizing TCL can push the anchor to its center in (a) but it cannot in (b).
(a)(b)


### 3.2. Search Space

Our key insight of constructing a search space and finding an optimal loss from it automatically lies in that (1) designing a loss architecture requires a lot of expert knowledge; (2) the available losses are all task- and dataset-dependent; (3) there is no rule of thumb to choose the hyperparameters for each loss.Therefore, we use the five loss architectures to construct the search space. Each loss comes with a magnitude. We discretize the range of the magnitudes into 11 values (uniform spacing) from 0.0 to 1.0 with a step of 0.1 so that we can use a discrete search algorithm to find them. Similarly, we also discretize the margin of each loss having a margin into 51 values (uniform spacing) from 0.0 to 5.0 with a step of 0.1. For the angular loss, we discretize the angle into 51 values (uniform spacing) from 10.0° to 60.0° with a step of 1.0°. Finding an optimal loss architecture now becomes a search problem in a space of 11×515≈5.6×1013 possibilities. Notice that there is no explicit discard action in our search space; this action is implicit and can be achieved by making the magnitude of a subloss architecture be 0.


### 3.3. Search Algorithm

The search algorithm we use to find the optimal loss architecture is a reinforcement learning algorithm (specifically, the proximal policy optimization (PPO)), inspired by [4, 27]. The loss generator is a one-layer LSTM with 100 hidden units. As shown in Figure 4, at each step, the generator takes an action according to the maximum probability produced by a softmax; the output is then fed into the next step. In total, the generator has 10 softmax layers in order to predict 5 subloss architectures, each with 2 actions (selecting a magnitude and a margin/angle).Figure 4
Recursively constructing loss architectures by the generator.As shown in Figure2, the generator is trained with a reward signal, which measures how good the loss architecture is at improving the accuracy of the object embedding network. After generating a loss architecture L with probability P, the embedding network is trained on the training set and fine-tuned using the few-shot instances. It is then evaluated on the validation set to measure the validation accuracy (the reward signal). At the end of the search, we obtain the best loss architecture L∗ with the highest accuracy on the validation set, which is then used to optimize the embedding network finally.


## 3.1. Losses

We choose five promising losses to construct the search space: Hard Mining Triplet Loss (HMTL) [23], Margin Sample Mining Loss (MSML) [24], Angular Loss (AL) [25], Triplet Center Loss (TCL) [26], and Quadruplet Center Loss (QCL). The first four are from the metric learning community, which achieve state-of-the-art results in few-shot learning, face recognition, vehicle Re-ID, person Re-ID, and so forth. The last one, QCL, is proposed in this paper and is a complement to the first four losses.


### 3.1.1. Hard Mining Triplet Loss

The triplet loss is based on a relative distance comparison among triplet instances. Specifically, for any tripletxai,xpi,xni where xai and xpi are two distinct samples of the same class and xni comes from another class as a negative example, their embedding vectors are generated by an embedding function fϕ such that hai=fϕxai, hpi=fϕxpi, and hni = fϕxni. The relative distance constraint of each triplet is defined as(1)Dhai,hpi+m≤Dhai,hni,where m is a predefined constant parameter representing the minimum margin between the matched and mismatched pairs, Dx,y is a metric function that measures distance between vectors x and y, and i denotes the i-th triplet. In order to ensure fast convergence, it is crucial to select triplets that violate the triplet constraint in equation (1). This means that, given xai, we want to select an xpi (hard positive sample) such that xpi=argmaxxpDfϕxai,fϕxp and to select xni (hard negative sample) such that xni=argminxnDfϕxai,fϕxn. For each sample (as an anchor) from a batch of size M, we select a hard-positive sample and a hard-negative sample (also from the batch) to construct a triplet. Thus, the HTML function can be defined as(2)LHMTL=1M∑i=1Mmax0,m+Dhai,hpi−Dhai,hni.


### 3.1.2. Margin Sample Mining Loss

The quadruplet loss (QL) [22] extends the triplet loss by adding a different negative pair1. A quadruplet contains four different instances xai,xpi,xn1i,xn2i, where xai and xpi are samples of the same class, while xn1i and xn2i are samples of two other classes. The quadruplet loss is formulated as(3)LQL=1NQL∑i=1NQLmax0,m1+Dhai,hpi−Dhai,hn1i+1NQL∑i=1NQLmax0,m2+Dhai,hpi−Dhn1i,hn2i,where m1 and m2 are two margins for the two terms, respectively, and NQL stands for the number of quadruplets. The first term is the same as the triplet loss. The second term tries to enforce intraclass distances to be smaller than interclass distances [22]. Based on QL, a strategy named margin sample mining is proposed [24]. It picks the most dissimilar positive pair xa,xp and the most similar negative pair xn1,xn1 in the whole batch and formulates its loss as(4)LMSML=max0,m+Dfϕxa,fϕxp−Dfϕxn1,fϕxn1.As shown in equation (4), the constraints of MSML are extremely sparse. Only two pairs in a batch are used to compute the gradient of the embedding network in the training phase, and it seems that it wastes a lot of training data. In fact, the two chosen pairs are determined by all the data in one batch. During training, more and more pairs will be selected [24].


### 3.1.3. Angular Loss

Let a tripletxai,xpi,xni form a triangle △xaixpixni whose sides are denoted as sap, san, and spn. The original triplet constraint equation (1) enforces that san is longer than sap. Because the anchor and positive samples are of the same class, a symmetrical triplet constraint can be derived, which enforces Dhai,hpi+m≤Dhpi,hni. According to the cosine formula, it can be proved that the angle ∠xaixnixpi surrounded by the longer edges san and spn has to be the smallest one; that is, ∠xaixnixpi≤min∠xnixaixpi,∠xaixpixni. Furthermore, because ∠xaixnixpi+∠xnixaixpi+∠xaixpixni=180°, ∠xaixnixpi has to be less than 60°, which can be used to constrain the upper bound ∠xaixnixpi for each triplet triangle [25]:(5)∠xaixnixpi≤α,where α is a predefined parameter. However, a straightforward implementation of equation (5) becomes unstable in some special cases [25]. In order to solve this problem, the angular loss function is defined in the following equation:(6)LAL=1NAL∑i=1NALmax0,Dhai,hpi−4Dhni,hai+hpi2tan2α,where NAL is the number of triplets, which is also equal to the batch size M in our implementation.


### 3.1.4. Triplet Center Loss

The goal of TCL is to leverage the advantages of the triplet loss and the center loss [39], that is, to effectively decrease the intraclass distances and increase the interclass distances simultaneously. Let a given training batch xi,yii=1M consist of M samples xi with the associated labels yi. In TCL, it is assumed that the features of each class share one center. Thus, the TCL is defined as(7)LTCL=1M∑i=1Mmax0,m+Dhai,cyi−Dhai,cn,where cyi is the center of class yi and cn is the negative center nearest to cyi.


### 3.1.5. Quadruplet Center Loss

In equation (7), TCL aims to make the distance between the anchor and its corresponding center cyi smaller than the distance between the anchor and its nearest negative center cn. For example, in Figure 3(a), the anchor can be pushed to its center. However, in some cases such as the one in Figure 3(b), it cannot, even though it is still far away from its center. In order to solve this problem, we propose a quadruplet center loss:(8)LQCL=1M∑i=1Mmax0,m+Dhai,cyi−minc1,c2Dc1,c2,where c1,c2 is a pair of centers. Thus, the proposed loss function guarantees that an anchor that is not close enough to its center will be moved closer, while an anchor that is already close enough to its center will be neglected.Figure 3
Two cases in TCL. Minimizing TCL can push the anchor to its center in (a) but it cannot in (b).
(a)(b)


## 3.1.1. Hard Mining Triplet Loss

The triplet loss is based on a relative distance comparison among triplet instances. Specifically, for any tripletxai,xpi,xni where xai and xpi are two distinct samples of the same class and xni comes from another class as a negative example, their embedding vectors are generated by an embedding function fϕ such that hai=fϕxai, hpi=fϕxpi, and hni = fϕxni. The relative distance constraint of each triplet is defined as(1)Dhai,hpi+m≤Dhai,hni,where m is a predefined constant parameter representing the minimum margin between the matched and mismatched pairs, Dx,y is a metric function that measures distance between vectors x and y, and i denotes the i-th triplet. In order to ensure fast convergence, it is crucial to select triplets that violate the triplet constraint in equation (1). This means that, given xai, we want to select an xpi (hard positive sample) such that xpi=argmaxxpDfϕxai,fϕxp and to select xni (hard negative sample) such that xni=argminxnDfϕxai,fϕxn. For each sample (as an anchor) from a batch of size M, we select a hard-positive sample and a hard-negative sample (also from the batch) to construct a triplet. Thus, the HTML function can be defined as(2)LHMTL=1M∑i=1Mmax0,m+Dhai,hpi−Dhai,hni.


## 3.1.2. Margin Sample Mining Loss

The quadruplet loss (QL) [22] extends the triplet loss by adding a different negative pair1. A quadruplet contains four different instances xai,xpi,xn1i,xn2i, where xai and xpi are samples of the same class, while xn1i and xn2i are samples of two other classes. The quadruplet loss is formulated as(3)LQL=1NQL∑i=1NQLmax0,m1+Dhai,hpi−Dhai,hn1i+1NQL∑i=1NQLmax0,m2+Dhai,hpi−Dhn1i,hn2i,where m1 and m2 are two margins for the two terms, respectively, and NQL stands for the number of quadruplets. The first term is the same as the triplet loss. The second term tries to enforce intraclass distances to be smaller than interclass distances [22]. Based on QL, a strategy named margin sample mining is proposed [24]. It picks the most dissimilar positive pair xa,xp and the most similar negative pair xn1,xn1 in the whole batch and formulates its loss as(4)LMSML=max0,m+Dfϕxa,fϕxp−Dfϕxn1,fϕxn1.As shown in equation (4), the constraints of MSML are extremely sparse. Only two pairs in a batch are used to compute the gradient of the embedding network in the training phase, and it seems that it wastes a lot of training data. In fact, the two chosen pairs are determined by all the data in one batch. During training, more and more pairs will be selected [24].


## 3.1.3. Angular Loss

Let a tripletxai,xpi,xni form a triangle △xaixpixni whose sides are denoted as sap, san, and spn. The original triplet constraint equation (1) enforces that san is longer than sap. Because the anchor and positive samples are of the same class, a symmetrical triplet constraint can be derived, which enforces Dhai,hpi+m≤Dhpi,hni. According to the cosine formula, it can be proved that the angle ∠xaixnixpi surrounded by the longer edges san and spn has to be the smallest one; that is, ∠xaixnixpi≤min∠xnixaixpi,∠xaixpixni. Furthermore, because ∠xaixnixpi+∠xnixaixpi+∠xaixpixni=180°, ∠xaixnixpi has to be less than 60°, which can be used to constrain the upper bound ∠xaixnixpi for each triplet triangle [25]:(5)∠xaixnixpi≤α,where α is a predefined parameter. However, a straightforward implementation of equation (5) becomes unstable in some special cases [25]. In order to solve this problem, the angular loss function is defined in the following equation:(6)LAL=1NAL∑i=1NALmax0,Dhai,hpi−4Dhni,hai+hpi2tan2α,where NAL is the number of triplets, which is also equal to the batch size M in our implementation.


## 3.1.4. Triplet Center Loss

The goal of TCL is to leverage the advantages of the triplet loss and the center loss [39], that is, to effectively decrease the intraclass distances and increase the interclass distances simultaneously. Let a given training batch xi,yii=1M consist of M samples xi with the associated labels yi. In TCL, it is assumed that the features of each class share one center. Thus, the TCL is defined as(7)LTCL=1M∑i=1Mmax0,m+Dhai,cyi−Dhai,cn,where cyi is the center of class yi and cn is the negative center nearest to cyi.


## 3.1.5. Quadruplet Center Loss

In equation (7), TCL aims to make the distance between the anchor and its corresponding center cyi smaller than the distance between the anchor and its nearest negative center cn. For example, in Figure 3(a), the anchor can be pushed to its center. However, in some cases such as the one in Figure 3(b), it cannot, even though it is still far away from its center. In order to solve this problem, we propose a quadruplet center loss:(8)LQCL=1M∑i=1Mmax0,m+Dhai,cyi−minc1,c2Dc1,c2,where c1,c2 is a pair of centers. Thus, the proposed loss function guarantees that an anchor that is not close enough to its center will be moved closer, while an anchor that is already close enough to its center will be neglected.Figure 3
Two cases in TCL. Minimizing TCL can push the anchor to its center in (a) but it cannot in (b).
(a)(b)


## 3.2. Search Space

Our key insight of constructing a search space and finding an optimal loss from it automatically lies in that (1) designing a loss architecture requires a lot of expert knowledge; (2) the available losses are all task- and dataset-dependent; (3) there is no rule of thumb to choose the hyperparameters for each loss.Therefore, we use the five loss architectures to construct the search space. Each loss comes with a magnitude. We discretize the range of the magnitudes into 11 values (uniform spacing) from 0.0 to 1.0 with a step of 0.1 so that we can use a discrete search algorithm to find them. Similarly, we also discretize the margin of each loss having a margin into 51 values (uniform spacing) from 0.0 to 5.0 with a step of 0.1. For the angular loss, we discretize the angle into 51 values (uniform spacing) from 10.0° to 60.0° with a step of 1.0°. Finding an optimal loss architecture now becomes a search problem in a space of 11×515≈5.6×1013 possibilities. Notice that there is no explicit discard action in our search space; this action is implicit and can be achieved by making the magnitude of a subloss architecture be 0.


## 3.3. Search Algorithm

The search algorithm we use to find the optimal loss architecture is a reinforcement learning algorithm (specifically, the proximal policy optimization (PPO)), inspired by [4, 27]. The loss generator is a one-layer LSTM with 100 hidden units. As shown in Figure 4, at each step, the generator takes an action according to the maximum probability produced by a softmax; the output is then fed into the next step. In total, the generator has 10 softmax layers in order to predict 5 subloss architectures, each with 2 actions (selecting a magnitude and a margin/angle).Figure 4
Recursively constructing loss architectures by the generator.As shown in Figure2, the generator is trained with a reward signal, which measures how good the loss architecture is at improving the accuracy of the object embedding network. After generating a loss architecture L with probability P, the embedding network is trained on the training set and fine-tuned using the few-shot instances. It is then evaluated on the validation set to measure the validation accuracy (the reward signal). At the end of the search, we obtain the best loss architecture L∗ with the highest accuracy on the validation set, which is then used to optimize the embedding network finally.


## 4. Experiments and Results

To evaluate the effectiveness of the proposed approach, we conduct experiments on three popular datasets for few-shot learning, CIFAR-100 [40], Omniglot [41], and mini-ImageNet [9]. Omniglot dataset is the most popular few-shot object recognition benchmark with handwritten characters, and mini-ImageNet dataset is a subset of ImageNet [5] released recently.


### 4.1. Datasets

#### 4.1.1. CIFAR-100 Dataset

The CIFAR-100 dataset [40] contains 60,000 32×32 images with 100 classes. We use 60, 20, and 20 classes for training, validation, and testing, respectively. The validation set is used to generate validation accuracies as the reward signals for LAS.


#### 4.1.2. Omniglot Dataset

This dataset contains 32,460 images of handwritten characters, with 1,623 different characters within 50 alphabets. We follow the most common split in [8], splitting the dataset into a background set of 1200 classes and a testing set of 423 classes. We further split the background set into a training set of 800 classes and a validation set of 400 classes.


#### 4.1.3. mini-ImageNet Dataset

The mini-ImageNet dataset is proposed by [9] as a benchmark with images of much higher resolutions and complexity. This dataset contains 100 classes randomly sampled from the ImageNet dataset, and each class contains 600 images. It is further split into a training set of 64 classes, a validation set of 16 classes, and a testing set of 20 classes [9].


### 4.2. Experimental Settings

#### 4.2.1. Evaluation Setting

Typically, a few-shot learning task withN new classes and k instances per class is referred to as an N-way k-shot task. In this paper, all experiments are for N-way k-shot object recognition, and the evaluation setting is similar to those in other compared methods. For each iteration in LAS (see the left part of Figure 2), we train the embedding network with the generated loss L using the training set. For evaluating L, we randomly select the k-shot instances as a support set consisting of N classes with k-labeled images per class from the validation set for fine-tuning the embedding network. Then, we randomly select 15 images (disjoint with the support set) within the selected N classes from the validation set to evaluate the fine-tuned embedding network by 1-Nearest Neighbor (1NN). We repeat such evaluation procedures 5 times for each support set and use the mean accuracy as the final validation accuracy (i.e., the reward signal) corresponding to L.After obtaining the final loss architectureL∗ for one dataset, we use the testing procedure to obtain the final accuracy (see the right part of Figure 2). We first train the embedding network with L∗ using the same training set. In the testing stage, we fine-tune the embedding network using a randomly selected support set from the testing set. After that, we randomly select 15 images (disjoint with the support set) within the selected N classes and then measure the classification accuracy by 1NN. To make the accuracy more convincing, we repeat such a testing procedure 600 times and report the final mean accuracy as well as the 95% Confidence Intervals (CIs).


#### 4.2.2. Network Architecture and Parameter Setting

Our embedding network follows the same architecture as that used in [8, 9], which has four convolutional layers (Conv-4). Each convolutional layer is designed with 3×3 convolution with 64 filters followed by batch normalization, ReLU nonlinearity, and 2×2 max pooling.On each dataset, the generator samples 5,000 loss architectures. We follow the training procedure and hyperparameters from [4] for training the generator. For training the embedding network, we use Adam [42] to perform stochastic optimization over the learning objective. The hyperparameters of Adam (i.e., β1, β2, and ε) are set to 0.9, 0.999, and 10−8, respectively.


### 4.3. Ablation Study

Since LAS integrates the five sublosses into the reinforcement learning framework, we conduct an ablation study on CIFAR-100 to understand the contribution of each subloss. In each case, we remove one subloss from the search space and perform the whole process of loss architecture search as shown in Figure2. The results are presented in Table 1.Table 1
Mean accuracy (%) ± CIs (%) of our LAS method in six cases on CIFAR-100 dataset.
Method5-way accuracy1-Shot5-ShotLAS (no HMTL)55.23 ± 0.7870.93 ± 0.74LAS (no MSML)55.14 ± 0.8170.89 ± 0.75LAS (no AL)55.21 ± 0.7369.81 ± 0.81LAS (no TCL)54.63 ± 0.7969.88 ± 0.76LAS (no QCL)54.56 ± 0.8369.50 ± 0.83LAS55.85 ± 0.7671.91 ± 0.73In each of the first five cases, one subloss is removed from the search space. In the last case, all the sublosses are used.From Table1, we can see that removing any one subloss results in an obvious performance drop compared with using all of them. This implies that the five losses are not redundant. In addition, removing QCL, the loss proposed in this paper, causes the most significant performance reduction on this dataset, which shows that QCL may contribute the most among the five losses.


### 4.4. Compared Methods

To verify the performance of our LAS for few-shot learning, we compare it with the following 19 state-of-the-art methods: (1) Siamese Network (SN) [21], which presents a strategy for performing few-shot classification by learning a deep convolutional embedding network with a pairwise Siamese loss, (2) Matching Network (MN) [8], which performs few-shot learning by embedding a small labeled support set and unlabeled examples, (3) Matching Network with Full Contextual Embeddings (MN-FCE) [8], which is an upgraded version of MN by utilizing a bi-LSTM to contextually embed samples, (4) Model Agnostic Metalearning (MAML) [29], which learns hyperparameters through gradient descent in a metalearning fashion, (5) Metalearner LSTM (ML-LSTM) [9], which uses a LSTM as a metalearner to learn the parameter update rule for optimizing the network, (6) Siamese with Memory (SM) [31], which proposes a large-scale life-long memory module to remember past training samples and makes predictions based on stored previous samples, (7) Metanetwork (Meta-N) [30], which learns metalevel knowledge across tasks for rapid generalization, (8) Meta-Stochastic Gradient Descent (Meta-SGD) [43], which learns the initialization, update direction, and learning rates by metalearning, (9) Prototypical Networks (PN) [10], which learn a prototype representation for each class, (10) Relation Network (RN) [20], which computes relation scores between few-shot instances and testing instances, (11) Memory Matching Network (MM-Net) [32], which augments CNNs with memory and learns the network parameters for unlabeled images, (12) MM-Net− [32], which is a variant of MM-Net by using a mixed training strategy, (13) Graph Neural Network (GNN) [44], which casts few-shot learning as a message passing task, (14) Task Agnostic Metalearning (TAML) [33], which learns an unbiased initial model with the largest uncertainty, (15) task-dependent adaptive metric (TADAM) [45], which proposes a practical end-to-end optimization procedure to learn a task-dependent metric space, (16) Simple Neural AttentIve Learner (SNAIL) [46], which proposes a generic metalearner architecture for few-shot learning, (17) Deep Nearest Neighbor Neural Network (DN4) [14], which replaces an image-level feature-based measure with a local feature-based image-to-class measure, and (18) deep learning with knowledge transfer architecture (KTN) [47], which jointly incorporates classifier learning, knowledge inferring, and visual feature learning into one framework.Note that, for fair comparison, the backbones of LAS and all these compared methods are of the same architecture as that used in [8, 9], which is a shallow network with only 4 convolutional layers.


### 4.5. Results on CIFAR-100

Table2 compares LAS with 4 state-of-the-art methods (MN, SM, MAML, and Meta-N) and the 5 sublosses described in the last section. The codes of these 4 methods are available publicly and thus can be used to run this experiment. The results across the 5-way 1-shot task and the 5-way 5-shot task show that our LAS method obtains the best performances against these methods. In particular, the 1-shot and 5-shot accuracy of our method can achieve 55.85% and 71.91%, respectively, on 5-way learning, making the absolute improvement over MAML by 6.56% and 5.87%.Table 2
Mean accuracy (%) ± CIs (%) of 4 state-of-the-art methods, the 5 sublosses, and LAS on the CIFAR-100 dataset.
Method5-way accuracy1-Shot5-ShotMN50.90 ± 1.0760.75 ± 0.94SM48.56 ± 0.8757.07 ± 0.86MAML49.29 ± 0.8966.04 ± 0.94Meta-N49.84 ± 0.9067.08 ± 0.90HMTL49.20 ± 0.8266.49 ± 0.99MSML49.73 ± 0.8467.48 ± 0.86AL51.34 ± 0.7468.84 ± 0.85TCL51.88 ± 0.9768.60 ± 0.81QCL52.09 ± 0.7868.97 ± 0.78LAS55.85 ± 0.7671.91 ± 0.73Table2 also shows the performances of 5 metric learning approaches for few-shot object recognition (HMTL [23], MSML [24], AL [25], TCL [26], and QCL). The results indicate that no single subloss dominates the loss searched by LAS.


### 4.6. Results on Omniglot

Table3 compares LAS with 8 state-of-the-art methods on the Omniglot dataset. The results of these methods are from [14, 32, 33]. The results across the 20-way 1-shot task and the 20-way 5-shot task indicate that our LAS method again achieves the best performances against other state-of-the-art techniques including embedding models (SN, MN, SM, PN, and MM-Net) and metalearning approaches (Meta-N, MAML, and TAML). In particular, the 1-shot and 5-shot accuracy of LAS can reach 97.69% and 99.21% on 20-way learning, respectively. It makes the absolute improvement over MAML by 1.89% and 0.31%, which is significant on this dataset.Table 3
Mean accuracy (%) ± CIs (%) of 8 state-of-the-art methods and LAS on the Omniglot dataset with Conv-4 as the backbone.
Method20-way accuracy1-Shot5-ShotSN†88.297.0MN†93.898.5SM†95.098.6Meta-N†97.0—PN§96.098.9MAML†95.8 ± 0.398.9 ± 0.2TAML∗95.12 ± 0.3998.58 ± 0.10MM-Net†97.16 ± 0.1098.93 ± 0.05LAS97.69 ± 0.1799.21 ± 0.09†Results from [32].∗Results from [33]. §Results from [14].


### 4.7. Results on mini-ImageNet

The performance comparison with 14 state-of-the-art methods on mini-ImageNet is summarized in Table4. The results of these methods are from [14, 20, 32, 33]. Our LAS method also performs the best. In particular, the 1-shot and 5-shot accuracy can achieve 54.97% and 71.92% on 5-way learning, respectively, making the absolute improvement over MM-Net by 1.60% and 4.95%. Compared with the most recent work DN4, LAS improves the accuracy of the two tasks by 3.73% and 0.90%, respectively. Our LAS gains 4.53% and 6.60% improvements over RN. RN computes relation scores between few-shot instances and the testing instances, while LAS finds the best metric learning-based loss to generate the best embedding functions.Table 4
Mean accuracy (%) ± CIs (%) of 14 state-of-the-art methods and LAS on the mini-ImageNet dataset with Conv-4 as the backbone.
Method5-way accuracy1-Shot5-ShotMN†43.40 ± 0.7851.09 ± 0.71MN-FCE†43.56 ± 0.8455.31 ± 0.73ML-LSTM†43.44 ± 0.7760.60 ± 0.71SNAIL∗45.1055.20MAML†48.70 ± 1.8463.11 ± 0.92Meta-N†49.21 ± 0.96—PN§49.42 ± 0.7868.20 ± 0.66GNN§49.02 ± 0.9863.50 ± 0.84RN‡50.44 ± 0.8265.32 ± 0.70Meta-SGD∗50.47 ± 1.8764.03 ± 0.94DN4§51.24 ± 0.7471.02 ± 0.64TAML∗51.77 ± 1.8665.60 ± 0.93MM-Net−†52.74 ± 0.4565.82 ± 0.37MM-Net†53.37 ± 0.4866.97 ± 0.35KTN†54.61 ± 0.8071.21 ± 0.66LAS55.14 ± 0.4671.92 ± 0.48†Results from [32]. ‡Results from [20]. ∗Results from [33]. §Results from [14].To evaluate the proposed method on deeper networks, several experiments on mini-ImageNet are conducted by using ResNet-12 as the backbone. ResNet-12 is a 12-layer residual network. The performance comparison with ResNet-12 as the backbone on mini-ImageNet is summarized in Table5. The results across the 5-way 1-shot task and the 5-way 5-shot task show that the proposed method achieves the best performances against other state-of-the-art techniques. In particular, the 1-shot and 5-shot accuracy of LAS with ResNet-12 as the backbone can reach 59.44% and 77.82% on 5-way learning, respectively. It makes the absolute improvement over MAML by 9.08% and 10.48%, which is significant on this dataset.Table 5
Mean accuracy (%) ± CIs (%) of 7 state-of-the-art methods and LAS on the mini-ImageNet dataset with ResNet-12 as the backbone.
Method5-way accuracy1-Shot5-ShotMN45.65 ± 0.8653.64 ± 0.81MAML50.36 ± 0.7867.34 ± 0.93Meta-N52.07 ± 0.8968.84 ± 0.87Meta-SGD52.96 ± 0.7569.52 ± 0.71SNAIL†55.71 ± 0.9968.88 ± 0.92MetaNet†57.10 ± 0.7070.04 ± 0.63TADAM†58.50 ± 0.3076.70 ± 0.30LAS59.44 ± 0.4177.82 ± 0.34†Results from [48].


### 4.8. Training and Inference Time

Similar to other reinforcement learning algorithms, the training of LAS is time-consuming. On Nvidia Tesla P100 GPU×2, LAS takes about two days to find the best loss architecture on the mini-ImageNet dataset for the 5-way 5-shot task. However, after training, its inference is fast enough; for example, it only takes 2 ms to perform one inference for the same task.


## 4.1. Datasets

### 4.1.1. CIFAR-100 Dataset

The CIFAR-100 dataset [40] contains 60,000 32×32 images with 100 classes. We use 60, 20, and 20 classes for training, validation, and testing, respectively. The validation set is used to generate validation accuracies as the reward signals for LAS.


### 4.1.2. Omniglot Dataset

This dataset contains 32,460 images of handwritten characters, with 1,623 different characters within 50 alphabets. We follow the most common split in [8], splitting the dataset into a background set of 1200 classes and a testing set of 423 classes. We further split the background set into a training set of 800 classes and a validation set of 400 classes.


### 4.1.3. mini-ImageNet Dataset

The mini-ImageNet dataset is proposed by [9] as a benchmark with images of much higher resolutions and complexity. This dataset contains 100 classes randomly sampled from the ImageNet dataset, and each class contains 600 images. It is further split into a training set of 64 classes, a validation set of 16 classes, and a testing set of 20 classes [9].


## 4.1.1. CIFAR-100 Dataset

The CIFAR-100 dataset [40] contains 60,000 32×32 images with 100 classes. We use 60, 20, and 20 classes for training, validation, and testing, respectively. The validation set is used to generate validation accuracies as the reward signals for LAS.


## 4.1.2. Omniglot Dataset

This dataset contains 32,460 images of handwritten characters, with 1,623 different characters within 50 alphabets. We follow the most common split in [8], splitting the dataset into a background set of 1200 classes and a testing set of 423 classes. We further split the background set into a training set of 800 classes and a validation set of 400 classes.


## 4.1.3. mini-ImageNet Dataset

The mini-ImageNet dataset is proposed by [9] as a benchmark with images of much higher resolutions and complexity. This dataset contains 100 classes randomly sampled from the ImageNet dataset, and each class contains 600 images. It is further split into a training set of 64 classes, a validation set of 16 classes, and a testing set of 20 classes [9].


## 4.2. Experimental Settings

### 4.2.1. Evaluation Setting

Typically, a few-shot learning task withN new classes and k instances per class is referred to as an N-way k-shot task. In this paper, all experiments are for N-way k-shot object recognition, and the evaluation setting is similar to those in other compared methods. For each iteration in LAS (see the left part of Figure 2), we train the embedding network with the generated loss L using the training set. For evaluating L, we randomly select the k-shot instances as a support set consisting of N classes with k-labeled images per class from the validation set for fine-tuning the embedding network. Then, we randomly select 15 images (disjoint with the support set) within the selected N classes from the validation set to evaluate the fine-tuned embedding network by 1-Nearest Neighbor (1NN). We repeat such evaluation procedures 5 times for each support set and use the mean accuracy as the final validation accuracy (i.e., the reward signal) corresponding to L.After obtaining the final loss architectureL∗ for one dataset, we use the testing procedure to obtain the final accuracy (see the right part of Figure 2). We first train the embedding network with L∗ using the same training set. In the testing stage, we fine-tune the embedding network using a randomly selected support set from the testing set. After that, we randomly select 15 images (disjoint with the support set) within the selected N classes and then measure the classification accuracy by 1NN. To make the accuracy more convincing, we repeat such a testing procedure 600 times and report the final mean accuracy as well as the 95% Confidence Intervals (CIs).


### 4.2.2. Network Architecture and Parameter Setting

Our embedding network follows the same architecture as that used in [8, 9], which has four convolutional layers (Conv-4). Each convolutional layer is designed with 3×3 convolution with 64 filters followed by batch normalization, ReLU nonlinearity, and 2×2 max pooling.On each dataset, the generator samples 5,000 loss architectures. We follow the training procedure and hyperparameters from [4] for training the generator. For training the embedding network, we use Adam [42] to perform stochastic optimization over the learning objective. The hyperparameters of Adam (i.e., β1, β2, and ε) are set to 0.9, 0.999, and 10−8, respectively.


## 4.2.1. Evaluation Setting

Typically, a few-shot learning task withN new classes and k instances per class is referred to as an N-way k-shot task. In this paper, all experiments are for N-way k-shot object recognition, and the evaluation setting is similar to those in other compared methods. For each iteration in LAS (see the left part of Figure 2), we train the embedding network with the generated loss L using the training set. For evaluating L, we randomly select the k-shot instances as a support set consisting of N classes with k-labeled images per class from the validation set for fine-tuning the embedding network. Then, we randomly select 15 images (disjoint with the support set) within the selected N classes from the validation set to evaluate the fine-tuned embedding network by 1-Nearest Neighbor (1NN). We repeat such evaluation procedures 5 times for each support set and use the mean accuracy as the final validation accuracy (i.e., the reward signal) corresponding to L.After obtaining the final loss architectureL∗ for one dataset, we use the testing procedure to obtain the final accuracy (see the right part of Figure 2). We first train the embedding network with L∗ using the same training set. In the testing stage, we fine-tune the embedding network using a randomly selected support set from the testing set. After that, we randomly select 15 images (disjoint with the support set) within the selected N classes and then measure the classification accuracy by 1NN. To make the accuracy more convincing, we repeat such a testing procedure 600 times and report the final mean accuracy as well as the 95% Confidence Intervals (CIs).


## 4.2.2. Network Architecture and Parameter Setting

Our embedding network follows the same architecture as that used in [8, 9], which has four convolutional layers (Conv-4). Each convolutional layer is designed with 3×3 convolution with 64 filters followed by batch normalization, ReLU nonlinearity, and 2×2 max pooling.On each dataset, the generator samples 5,000 loss architectures. We follow the training procedure and hyperparameters from [4] for training the generator. For training the embedding network, we use Adam [42] to perform stochastic optimization over the learning objective. The hyperparameters of Adam (i.e., β1, β2, and ε) are set to 0.9, 0.999, and 10−8, respectively.


## 4.3. Ablation Study

Since LAS integrates the five sublosses into the reinforcement learning framework, we conduct an ablation study on CIFAR-100 to understand the contribution of each subloss. In each case, we remove one subloss from the search space and perform the whole process of loss architecture search as shown in Figure2. The results are presented in Table 1.Table 1
Mean accuracy (%) ± CIs (%) of our LAS method in six cases on CIFAR-100 dataset.
Method5-way accuracy1-Shot5-ShotLAS (no HMTL)55.23 ± 0.7870.93 ± 0.74LAS (no MSML)55.14 ± 0.8170.89 ± 0.75LAS (no AL)55.21 ± 0.7369.81 ± 0.81LAS (no TCL)54.63 ± 0.7969.88 ± 0.76LAS (no QCL)54.56 ± 0.8369.50 ± 0.83LAS55.85 ± 0.7671.91 ± 0.73In each of the first five cases, one subloss is removed from the search space. In the last case, all the sublosses are used.From Table1, we can see that removing any one subloss results in an obvious performance drop compared with using all of them. This implies that the five losses are not redundant. In addition, removing QCL, the loss proposed in this paper, causes the most significant performance reduction on this dataset, which shows that QCL may contribute the most among the five losses.


## 4.4. Compared Methods

To verify the performance of our LAS for few-shot learning, we compare it with the following 19 state-of-the-art methods: (1) Siamese Network (SN) [21], which presents a strategy for performing few-shot classification by learning a deep convolutional embedding network with a pairwise Siamese loss, (2) Matching Network (MN) [8], which performs few-shot learning by embedding a small labeled support set and unlabeled examples, (3) Matching Network with Full Contextual Embeddings (MN-FCE) [8], which is an upgraded version of MN by utilizing a bi-LSTM to contextually embed samples, (4) Model Agnostic Metalearning (MAML) [29], which learns hyperparameters through gradient descent in a metalearning fashion, (5) Metalearner LSTM (ML-LSTM) [9], which uses a LSTM as a metalearner to learn the parameter update rule for optimizing the network, (6) Siamese with Memory (SM) [31], which proposes a large-scale life-long memory module to remember past training samples and makes predictions based on stored previous samples, (7) Metanetwork (Meta-N) [30], which learns metalevel knowledge across tasks for rapid generalization, (8) Meta-Stochastic Gradient Descent (Meta-SGD) [43], which learns the initialization, update direction, and learning rates by metalearning, (9) Prototypical Networks (PN) [10], which learn a prototype representation for each class, (10) Relation Network (RN) [20], which computes relation scores between few-shot instances and testing instances, (11) Memory Matching Network (MM-Net) [32], which augments CNNs with memory and learns the network parameters for unlabeled images, (12) MM-Net− [32], which is a variant of MM-Net by using a mixed training strategy, (13) Graph Neural Network (GNN) [44], which casts few-shot learning as a message passing task, (14) Task Agnostic Metalearning (TAML) [33], which learns an unbiased initial model with the largest uncertainty, (15) task-dependent adaptive metric (TADAM) [45], which proposes a practical end-to-end optimization procedure to learn a task-dependent metric space, (16) Simple Neural AttentIve Learner (SNAIL) [46], which proposes a generic metalearner architecture for few-shot learning, (17) Deep Nearest Neighbor Neural Network (DN4) [14], which replaces an image-level feature-based measure with a local feature-based image-to-class measure, and (18) deep learning with knowledge transfer architecture (KTN) [47], which jointly incorporates classifier learning, knowledge inferring, and visual feature learning into one framework.Note that, for fair comparison, the backbones of LAS and all these compared methods are of the same architecture as that used in [8, 9], which is a shallow network with only 4 convolutional layers.


## 4.5. Results on CIFAR-100

Table2 compares LAS with 4 state-of-the-art methods (MN, SM, MAML, and Meta-N) and the 5 sublosses described in the last section. The codes of these 4 methods are available publicly and thus can be used to run this experiment. The results across the 5-way 1-shot task and the 5-way 5-shot task show that our LAS method obtains the best performances against these methods. In particular, the 1-shot and 5-shot accuracy of our method can achieve 55.85% and 71.91%, respectively, on 5-way learning, making the absolute improvement over MAML by 6.56% and 5.87%.Table 2
Mean accuracy (%) ± CIs (%) of 4 state-of-the-art methods, the 5 sublosses, and LAS on the CIFAR-100 dataset.
Method5-way accuracy1-Shot5-ShotMN50.90 ± 1.0760.75 ± 0.94SM48.56 ± 0.8757.07 ± 0.86MAML49.29 ± 0.8966.04 ± 0.94Meta-N49.84 ± 0.9067.08 ± 0.90HMTL49.20 ± 0.8266.49 ± 0.99MSML49.73 ± 0.8467.48 ± 0.86AL51.34 ± 0.7468.84 ± 0.85TCL51.88 ± 0.9768.60 ± 0.81QCL52.09 ± 0.7868.97 ± 0.78LAS55.85 ± 0.7671.91 ± 0.73Table2 also shows the performances of 5 metric learning approaches for few-shot object recognition (HMTL [23], MSML [24], AL [25], TCL [26], and QCL). The results indicate that no single subloss dominates the loss searched by LAS.


## 4.6. Results on Omniglot

Table3 compares LAS with 8 state-of-the-art methods on the Omniglot dataset. The results of these methods are from [14, 32, 33]. The results across the 20-way 1-shot task and the 20-way 5-shot task indicate that our LAS method again achieves the best performances against other state-of-the-art techniques including embedding models (SN, MN, SM, PN, and MM-Net) and metalearning approaches (Meta-N, MAML, and TAML). In particular, the 1-shot and 5-shot accuracy of LAS can reach 97.69% and 99.21% on 20-way learning, respectively. It makes the absolute improvement over MAML by 1.89% and 0.31%, which is significant on this dataset.Table 3
Mean accuracy (%) ± CIs (%) of 8 state-of-the-art methods and LAS on the Omniglot dataset with Conv-4 as the backbone.
Method20-way accuracy1-Shot5-ShotSN†88.297.0MN†93.898.5SM†95.098.6Meta-N†97.0—PN§96.098.9MAML†95.8 ± 0.398.9 ± 0.2TAML∗95.12 ± 0.3998.58 ± 0.10MM-Net†97.16 ± 0.1098.93 ± 0.05LAS97.69 ± 0.1799.21 ± 0.09†Results from [32].∗Results from [33]. §Results from [14].


## 4.7. Results on mini-ImageNet

The performance comparison with 14 state-of-the-art methods on mini-ImageNet is summarized in Table4. The results of these methods are from [14, 20, 32, 33]. Our LAS method also performs the best. In particular, the 1-shot and 5-shot accuracy can achieve 54.97% and 71.92% on 5-way learning, respectively, making the absolute improvement over MM-Net by 1.60% and 4.95%. Compared with the most recent work DN4, LAS improves the accuracy of the two tasks by 3.73% and 0.90%, respectively. Our LAS gains 4.53% and 6.60% improvements over RN. RN computes relation scores between few-shot instances and the testing instances, while LAS finds the best metric learning-based loss to generate the best embedding functions.Table 4
Mean accuracy (%) ± CIs (%) of 14 state-of-the-art methods and LAS on the mini-ImageNet dataset with Conv-4 as the backbone.
Method5-way accuracy1-Shot5-ShotMN†43.40 ± 0.7851.09 ± 0.71MN-FCE†43.56 ± 0.8455.31 ± 0.73ML-LSTM†43.44 ± 0.7760.60 ± 0.71SNAIL∗45.1055.20MAML†48.70 ± 1.8463.11 ± 0.92Meta-N†49.21 ± 0.96—PN§49.42 ± 0.7868.20 ± 0.66GNN§49.02 ± 0.9863.50 ± 0.84RN‡50.44 ± 0.8265.32 ± 0.70Meta-SGD∗50.47 ± 1.8764.03 ± 0.94DN4§51.24 ± 0.7471.02 ± 0.64TAML∗51.77 ± 1.8665.60 ± 0.93MM-Net−†52.74 ± 0.4565.82 ± 0.37MM-Net†53.37 ± 0.4866.97 ± 0.35KTN†54.61 ± 0.8071.21 ± 0.66LAS55.14 ± 0.4671.92 ± 0.48†Results from [32]. ‡Results from [20]. ∗Results from [33]. §Results from [14].To evaluate the proposed method on deeper networks, several experiments on mini-ImageNet are conducted by using ResNet-12 as the backbone. ResNet-12 is a 12-layer residual network. The performance comparison with ResNet-12 as the backbone on mini-ImageNet is summarized in Table5. The results across the 5-way 1-shot task and the 5-way 5-shot task show that the proposed method achieves the best performances against other state-of-the-art techniques. In particular, the 1-shot and 5-shot accuracy of LAS with ResNet-12 as the backbone can reach 59.44% and 77.82% on 5-way learning, respectively. It makes the absolute improvement over MAML by 9.08% and 10.48%, which is significant on this dataset.Table 5
Mean accuracy (%) ± CIs (%) of 7 state-of-the-art methods and LAS on the mini-ImageNet dataset with ResNet-12 as the backbone.
Method5-way accuracy1-Shot5-ShotMN45.65 ± 0.8653.64 ± 0.81MAML50.36 ± 0.7867.34 ± 0.93Meta-N52.07 ± 0.8968.84 ± 0.87Meta-SGD52.96 ± 0.7569.52 ± 0.71SNAIL†55.71 ± 0.9968.88 ± 0.92MetaNet†57.10 ± 0.7070.04 ± 0.63TADAM†58.50 ± 0.3076.70 ± 0.30LAS59.44 ± 0.4177.82 ± 0.34†Results from [48].


## 4.8. Training and Inference Time

Similar to other reinforcement learning algorithms, the training of LAS is time-consuming. On Nvidia Tesla P100 GPU×2, LAS takes about two days to find the best loss architecture on the mini-ImageNet dataset for the 5-way 5-shot task. However, after training, its inference is fast enough; for example, it only takes 2 ms to perform one inference for the same task.


## 5. Conclusion

In this paper, we have proposed an automatic approach to best loss architecture search for few-shot object recognition. Five metric learning-based sublosses (with one developed by us) are used to construct the search space. The loss generator is trained by a reinforcement learning algorithm. Our experiments show that the proposed few-shot object recognition method outperforms other state-of-the-art methods on three popular benchmarks. The future work includes combining network architecture search and loss architecture search for better AutoML.



---

*Source: 1041962-2020-08-24.xml*