Few-Shot Incremental Learning with Continually Evolved Classifiers

Chi Zhang, Nan Song, Guosheng Lin, Yun Zheng, Pan Pan, Yinghui Xu

Introduction

Deep Convolutional Neural Networks have gained remarkable success in many computer vision tasks , stemming from the availability of big curated datasets, along with unprecedented computing power. However, a classification model that is trained by supervised learning can only make predictions on a set of pre-defined image categories. If we want to extend a trained model on new classes, a large amount of labeled data for new classes as well as data from old classes are both necessary for network finetuning, which inevitably hinders its real-world applications. If the dataset of old classes is no longer available, directly finetuning a deployed model with new classes can lead to the notorious catastrophic forgetting problem that knowledge about old classes is quickly forgotten . In contrast to machine learning systems, humans are readily able to learn a new concept with few examples without forgetting old knowledge. The gap between humans and the machine learning algorithms fuels interest in few-shot class-incremental learning (FSCIL) , which aims to design machine learning algorithms that can be continually extended to new classes with only a few data points. The challenge of FSCIL lies in that the scarcity in the data of new classes will not only cause severe overfitting but also exacerbates the catastrophic forgetting problem of old classes. In this paper, we undertake the task of few shot incremental learning and consider to solve the aforementioned problems from two aspects.

First, as the data from base classes and new classes are severely unbalanced, we propose to decouple the learning of representations and classifiers for the FSCIL problem. Specifically, the model only learns the representations in the first session where abundant data from base classes are available, and in the new sessions, we fix the network backbone and only adapt the classifier for new classes. Thus, we can avoid the overfitting problem as well as the catastrophic forgetting problem in the representations. By doing so, we demonstrate that a pre-trained network backbone based on data from base classes plus a class mean classifier can beat state-of-the-art approaches.

Second, as the classifiers are always learned from the classes in individual incremental sessions, they can only provide discriminative information for classifying internal categories, while incremental learning aims to learn models that can apply to all classes. As a result, even if a classifier can learn a well-separated decision boundary for the previous classes, it may lose the generalization ability when more novel classes are involved. For example, a vehicle-related representation wheel is chosen by the classifier as a discriminative representation to distinguish the categories car, dog and cup in the current classification task. However, when a new category trunk is involved in the new sessions, such representation may not be discriminative enough to classify all categories. Therefore, the incremental learning algorithm should have the flexibility to adjust the classifiers in previous sessions based on the overall task context to undertake the entire classification task. To this end, we present a Continually Evolved Classifier (CEC) that can progressively adapt the classifier weights based on current and history tasks. At the core of our network is a classifier adaptation module which uses a graph attention network (GAT) to adapt the classifier weights learned on each task. By contextualizing individual classifier weights over the global task, the adapted classifiers highlight the discriminative representations in the backbone and generate better decision boundaries over all involved classes.

To enable the learning of the proposed continually evolved classifier, it is important to optimize the graph model under an incremental learning scenario. However, in incremental learning, datasets from different training sessions can never be accessed simultaneously for training. To overcome the issue, we propose a pseudo incremental learning paradigm, where we episodically construct a pseudo incremental learning task from the dataset in the base session to simulate the incremental learning scenario for training. Our design takes inspirations from the meta-learning paradigm . In each pseudo incremental learning episode, we first sample a set of classes from the base dataset to play the role of the base classes, then we sample another group of classes to play the role of incremental classes to learn the model. However, as the pre-trained backbone has already learned feature representations that can well classify the base classes, directly using the sampled classes from the base dataset for learning may bypass the GAT and thus fail to impose context knowledge. We solve this problem by randomly rotating the sampled pseudo incremental classes with a large angle to synthesize new classes. In this way, we intentionally synthesize unfamiliar classes at training time to enforce context knowledge propagation in the graph model. Once the graph model is learned, we can use the graph model to update the classifier weights learned in incremental sessions.

To validate the effectiveness of our proposed method, we conduct comprehensive experiments on multiple benchmark datasets. The contribution of this work is summarized as follows:

We adopt a decoupled training strategy for representation learning and classifier learning to avoid knowledge forgetting and overfitting in the backbone.

We propose a continually evolved classifier that employs a graph model to combine classifiers learned on individual sessions for incremental learning.

To enable the learning of the graph model in CEC, we design a pseudo incremental learning paradigm.

Experiments on the CIFAR100, CUB200 and miniImagenet datasets show that our method significantly outperforms the baselines and sets new state-of-the-art performance with remarkable advantages.

Related Work

Few-Shot Learning. Few-shot learning aims to learn a model that can classify unseen images when only training from scarce labeled training examples . Research literature on few-shot learning demonstrates great diversity. Optimization-based methods and metric-based methods are two main lines of efforts. Optimization-based methods aims to design efficient learning paradigm that enables fast network adaptation given limited data . Our work is more related to metric-based approaches, where a pre-trained backbone is used to encode data, and a distance metric, such as negative L2 distance , cosine similarity and DeepEMD , is used to measure data similarity and compute scores. Chen et al. presents a baseline for few-shot classification that first pre-trains a backbone based on data from seen classes, and only finetunes the classifier for novel classes, which shares similarity with our decoupled training strategy. Apart from image classification, few-shot learning has also been applied to dense prediction tasks and object detection .

Incremental Learning. Incremental learning (IL) is an active machine learning task that aims to learn new knowledge continually without forgetting . Recent works falls in two main streams, the multi-class incremental learning and the multi-task incremental learning . Early approaches for IL use knowledge distillation to transfer knowledge from the old model to a new model. iCaRL learns a nearest-neighbor classifier with exemplars to preserve performance and combines distillation loss to avoid forgetting. EEIL introduces an end-to-end framework with cross-entropy loss and distillation loss for IL. LUCIR learns a unified classifier to solve the class imbalance problem between the base and new classes. Liu et al. propose mnemonics training through bilevel optimizations in model-level and exemplar-level for tackling multi-class incremental learning.

Few-Shot Class-Incremental Learning. FSCIL is recently proposed with the goal of undertaking the CIL task with limited data in incremental sessions. It can also been seen as a few-shot learning task that can classify both novel and old classes at the same time. Tao et al. propose a neural gas network to preserve the topology of the features in the base and new classes for the FSCIL task. Ren et al. also undertake the few-shot incremental learning task but with a different setting. Our work mainly follows the task definition proposed in which is more closed to the setting in incremental learning literature.

Problem Set-up

FSCIL aims to design a machine learning algorithm that can continually learn novel classes from only a few new training examples without forgetting knowledge about old classes. Usually, FSCIL has several learning sessions that come in sequence. Once the learning of model steps into the next session, the training dataset in previous learning sessions are no longer available, while the evaluation of the FSCIL algorithm in each session involves classes in all previous sessions and the current session. To be specific, let {Dtrain0,Dtrain1,⋯ ,Dtrainn}\{\mathcal{D}_{train}^{0},\mathcal{D}_{train}^{1},\cdots,\mathcal{D}_{train}^{n}\} denotes the training sets of different learning sessions, and the corresponding label space of dataset Dtraini\mathcal{D}_{train}^{i} is denoted by Ci\mathcal{C}^{i}. Different datasets have no overlapped classes, \ie∀i,j\forall i,j and i≠j,Ci∩Cj=∅i\neq j,\mathcal{C}^{i}\cap\mathcal{C}^{j}=\varnothing. At the iith learning session, only Dtraini\mathcal{D}_{train}^{i} can be used for network training, and for evaluation, the test dataset Dtestn\mathcal{D}_{test}^{n} at session ii include test data from all previous and current classes, \ie, the label space of C0∪C1⋯∪Cn\mathcal{C}^{0}\cup\mathcal{C}^{1}\cdots\cup\mathcal{C}^{n}. Usually, the training set Dtrain0\mathcal{D}_{train}^{0} in the first session is a relatively large dataset where a sufficient amount of data is available for training, which is also called the base training set. On the contrary, the datasets in all following sessions have only a limited amount of data, and the dataset Dtraini\mathcal{D}_{train}^{i} on a specific session is often described as a N−N-way K−K-shot training set, where there are NN classes in the dataset, and each class has KK training images. For example, in the popular benchmark dataset CIFAR100, there are 60 classes in the base sessions, and each class has 500 training images, while in each incremental session, only 5 classes are available for training and each class only has 5 images. FSCIL defines a harsh problem setting, where the severe data imbalance and scarcity problems will further exacerbate knowledge forgetting in incremental learning.

Method

In this section, we introduce our framework for few-shot incremental learning. We first describe our decoupled training strategy of representations and classifiers in Section 4.1. Then we present our proposed continually evolved classifier in Section 4.2. To enable the learning of CEC, we design a pseudo incremental learning algorithm, which is described in Section 4.3. The overview of the whole training pipeline is shown in Fig. 2.

Our few-shot incremental learning framework mainly includes three training stages: the feature pre-training stage, the pseudo-incremental learning stage, and the classifier learning stage, as shown in Fig. 2. The first two stages use data from the base sessions to learn the network backbone and the classifier adaptation module, and the classifier learning stage only learns the network classifier in each new incoming session.

Feature pre-training stage. It is commonly evidenced in previous incremental learning literature that finetuning the network in new sessions can lead to significant knowledge forgetting of old classes. The data shortage problem in the few-shot incremental learning will further introduce the overfitting problem that exacerbates knowledge forgetting. To tackle this problem, we propose to decouple the learning of representations and classifiers to avoid the catastrophic forgetting issue at incremental stages. Specifically, we first train a convolutional neural network in the standard manner with the training dataset in the base session where abundant data are available for learning image representations, and we can then reuse the network backbone to encode image data in all sessions. By freezing backbone parameters in new sessions, we can avoid knowledge forgetting and overfitting in the representations when learning the model on new sessions.

Pseudo incremental learning stage. Based on the pre-trained backbone model, we learn the classifier adaptation module to enable the function of the CEC, which is also based on the base dataset. The adaptation module is frozen after training and is used to to update the classifiers learned on individual sessions. We leave the detailed description of the classifier adaptation module and the training paradigm in Section 4.2 and Section 4.3.

Classifier learning stage. Once the feature backbone and the graph models are learned in the base session, our model can be deployed for incremental learning. We only need to learn a classifier upon the fixed backbone network with the dataset in new sessions, and then the learned classifiers in the current session and previous sessions are fed to the graph model for adaptation. Finally, the updated classifiers can be used for evaluation.

2 Continually Evolved Classifier

To illustrate the context propagation process in the GAT, we take the updating of a node jj in the graph as an example. We first compute a relation coefficient ejke_{jk} between the node jj and all nodes in the graph, such as w⃗j\vec{w}^{j} and w⃗k\vec{w}^{k} :

Based on the normalized attention coefficients ajka_{jk}, we aggregate information from all the nodes in the graph based on ajka_{jk} and fuse it with the original node representation to obtain w⃗j′\vec{w}^{j\prime}:

where U\mathbf{U} is the weight matrix of a linear transformation. We repeat the operations above to update the embeddings of all nodes in the graph, and finally we obtain the updated classifiers:

In each incoming session, we use the adaptation module to update the classifiers learned in the current session and previous sessions, and then concatenate the updated classifiers to make predictions over all classes. Many useful practices can be adopted to improve the knowledge propagation, such as multi-head attention , layer normalization , and dropout . We also follow that incorporates the embedding of the network input into the graph to help the learning of context knowledge.

3 Pseudo Incremental Learning

In order to enforce context encoding in the classifier adaptation module, it is important to learn the GAT under the incremental learning scenario. However, in FSCIL, only data from a single session are available for training, and the amount of data in incremental sessions is always limited. To overcome this problem, we design a pseudo incremental learning algorithm to train the adaptation module by episodically constructing pseudo incremental tasks based on the base dataset Dtrain0\mathcal{D}_{train}^{0} to mimic the test scenario. The pseudo code of the proposed algorithm is illustrated in Alg. ‣ 1. Our algorithm takes inspirations from meta-learning , where a small classification task is constructed to enable learning on the meta-level beyond a specific task. We utilize data from the base dataset Dtrain0\mathcal{D}_{train}^{0} to construct small incremental learning tasks for network training, where some sampled classes play the role of the base classes in incremental learning, while the other classes play the role of the incremental classes. Specifically, both pseudo incremental classes and pseudo base classes have the support set and the query set, which are denoted by (Sb,Qb)(\mathcal{S}_{b},\mathcal{Q}_{b}) and (Si,Qi)(\mathcal{S}_{i},\mathcal{Q}_{i}), respectively. The support set is used to learn the classifier weights of different classes, and the query set is used to compute loss for optimization. To be concrete, we first use the support sets (Sb(\mathcal{S}_{b} and Si)\mathcal{S}_{i}) to learn two classifiers, (Wb′(\mathbf{W}_{b}^{\prime} and Wi′)\mathbf{W}_{i}^{\prime}), for pseudo base classes and pseudo incremental classes respectively. Then, the two classifiers are concatenated and fed into the adaptation module Gθ\mathcal{G}_{\theta} for updating. We use the updated classifiers (Wb′,Wi′)(\mathbf{W}_{b}^{\prime},\mathbf{W}_{i}^{\prime}) to make predictions for the query sets of pseudo base classes and pseudo incremental classes, \ie, Qb\mathcal{Q}_{b} and Qi\mathcal{Q}_{i}, and compute the loss to optimize the adaptation module Gθ\mathcal{G}_{\theta}. We also finetune the last layer of the backbone with a small learning rate during PIL, which we find helpful. In our experiment, we find that directly splitting the sampled base classes into two groups to train the adaptation module fails. A possible reason is that the backbone model pre-trained on base classes can well separate these sampled classes already without context information. As a result, the training may simply bypass the adaptation module. To handle this issue, we randomly rotate the data of the sampled pseudo incremental classes, (Si,Qi)(\mathcal{S}_{i},\mathcal{Q}_{i}), with a large class-wise angle γ\gamma to synthesis new classes, as we observe that rotating data with a large angle can make the synthesized images lose parts of the semantics of their original classes, but demonstrate similar semantics among synthesized images. Once the adaptation module is learned, we can freeze the parameters in the adaptation module and deploy it in the new incremental sessions.

Experiments

In this section, we evaluate our proposed CEC on three popular few-shot incremental learning benchmark datasets, including CIFAR100 , miniImageNet and Caltech-UCSD Birds-200-2011 (CUB200) . We first present the experiment details and dataset statistics. Then we conduct comprehensive experiments to validate the the effectiveness of individual components in our design and study their characteristics. Finally, we compare our network with state-of-the-art methods on the benchmarks.

CIFAR100. CIFAR100 is a classification dataset with 60,000 32×3232\times 32 RGB images from 100 classes. Each class contains 500 training images and 100 testing images. We follow the splits in , where 60 classes and 40 classes are used as base classes and new classes, respectively. The 40 new classes are further divided into 8 new incremental sessions, and each new session is a 5-way 5-shot classification task.

miniImageNet. miniImageNet contains 100 classes with 600 images in each class, which are built upon the ImageNet dataset . The image size of miniImageNet is 84×8484\times 84 and we follow to split the 100 classes into 60 base classes and 40 incremental classes. The 40 new classes are further divided equally into 8 sessions with 5 classes in each session, and each class has 5 training images in the incremental sessions.

Caltech-UCSD Birds-200-2011. CUB200 was originally proposed for fine-grained image classification. It contains 11,788 images from 200 classes. We follow the splits in that 200 classes are divided into 100 base classes and 100 new classes, respectively. The 100 new classes are further divided into 10 new sessions where each session is a 10-way 5-shot task. The images size in CUB200 is 224×224224\times 224.

2 Implementation Details

Following , we employ ResNet20 as the backbone for experiments on CIFAR100 and ResNet18 for experiments on miniImageNet and CUB200. Our network is built with PyTorch library, and we use SGD with momentum for optimization. At the pseudo incremental learning stage, we random choose the angle γ\gamma from {90∘,180∘,270∘}\{90^{\circ},180^{\circ},270^{\circ}\} to synthesize new classes. We train the graph model Gθ\mathcal{G}_{\theta} for 5000 iterations with the learning rate of 0.0002. The learning rate is decayed by 0.5 every 1000 iteration. Random crop, random scale, and random horizontal flip are used for data augmentation at training time.

Evaluation Protocol. We evaluate the model after each session with the test set Dtesti\mathcal{D}_{test}^{i} and report the Top 1 accuracy. We also define a performance dropping rate (PD) that measures the absolute accuracy drops in the last session w.r.t. the accuracy in the first session, \ie, PD=A0−AN\text{PD}=\mathcal{A}_{0}-\mathcal{A}_{N}, where A0\mathcal{A}_{0} is the classification accuracy in the base session and AN\mathcal{A}_{N} is the accuracy in the last session.

3 Analysis

In this part, we implement various experiments to evaluate the effectiveness of our algorithm and study the characteristics of different components. For analysis, we mainly report the results on the CUB200 dataset and leave other datasets in Section 5.4 and our supplementary material.

Ablation study. In the beginning, we conduct an ablative analysis on the CUB200 dataset to observe the effectiveness of the different components in our model. We first consider four kinds of classifiers, including the vanilla linear classifier in the CNNs, the cosine classifier , the L2 classifier , and the DeepEMD classifier , where their main difference is the metric to compute class scores given the prototypes of each class. In new incremental sessions, the classifier is learned with a learning rate of 0.1 for 100 epochs. We also try using the data embeddings to parameterize the classifier weights where the weight vector of each class is initialized by the average data embeddings in the training set, which is denoted by Data Init. We gradually involve our designs to observe their influence on performance, including decoupled training scheme (Decoupled), the adaptation module (AM), and the pseudo incremental learning paradigm (PIL). When our adaptation module is not trained with pseudo incremental learning, we adopt the meta-learning to learn the parameters in the graph. The result is shown in Table 1. For both cosine classifier and the linear classifier, decoupling the representation learning and the classifier learning is useful for avoiding the catastrophic forgetting issue, which can decrease the performance dropping rate by 28.81% and 3.39%, respectively. Using the data embeddings to initialize the classifier weights is beneficial to all classifiers. When both the decoupled training strategy and data initialization are adopted, all four classifiers can achieve good performance, and cosine classifier performs the best. Without further specification, we use the cosine classifier in rest experiments. Using meta-learning to learn the adaptation module fails to improve the performance. When the adaptation module is learned by our proposed PIL, it can boost the performance over all sessions by up to 3.13% and can decrease performance dropping rate by 2.87%.

Confusion Matrix. To further observe the behavior in the adaptation module, we plot the confusion matrix generated by the models with and without our adaptation module in Fig. 3. As we can see, the classifier without adaptation generates a confusing matrix, particularly for the incremental classes (the prediction distribution is more scattered and thus darker). In contrast, our adaptation module can effectively improve the predictions where the values more lie in the diagonal that indicates the ground truth.

Visualization of adaptation. We plot the data embeddings and classifier weights in low-dimension space with t-SNE in Fig. 4. We randomly choose five classes from the CIFAR100 dataset as the base classes, and we add four new classes as the incremental classes. As can be seen, the adaptation module moves the classifier weights away from the confusion area to generate better decision boundaries when new classes are involved.

Analysis of pseudo incremental learning. We next investigate the configurations in the pseudo incremental learning scheme. In particular, we fix the query number as 10 and analyze the influence of ways, shots and the rotation angles during pseudo incremental learning. We set the same ways, shots and queries for pseudo base classes and pseudo incremental classes. The comparison is shown in Fig. 5. We choose the number of ways from {1,5,10,15,20}\{1,5,10,15,20\} and the number of shots from {1,5,10,15,20}\{1,5,10,15,20\}. We find that a relatively larger way and a smaller shot are better, and the optimal result is obtained when the way is 15 and the shot is 1.

We then fix the way and shot, and investigate the rotation degrees for classes synthesis in PIL. We choose different rotation degrees for comparison and present their results in Fig. 6. Our tested degrees include 180∘180^{\circ}, ±90∘\pm 90^{\circ}, ±45∘\pm 45^{\circ}, ±20∘\pm 20^{\circ}, ±10∘\pm 10^{\circ} and ±5∘\pm 5^{\circ}. As we can see, large angles, such as 180∘180^{\circ}, 90∘90^{\circ} and −90∘-90^{\circ} (270∘270^{\circ}) are more effective for class synthesis and generate higher average accuracy and lower performance dropping rate. When the rotation degree is small, the synthesized classes may be confused with the original classes and thus generate poor results. When the three large degrees, \ie, {180∘180^{\circ}, 90∘90^{\circ}, −90∘-90^{\circ}(270∘270^{\circ}) } are randomly selected for training, it generates the best result with the highest average accuracy of 61.33%61.33\% and lowest dropping rate of 23.57%23.57\%.

4 Comparison with the State-of-the-Art Methods

Finally, we compare our performance with the state-of-the-art results on three benchmarks: CIFAR100, miniImagenet, and CUB200. We show the results in Fig. 7 and the detailed numbers for CUB200 in Table 2 (Please refer to our supplementary material for results on other datasets). Our model has the highest average accuracy over all sessions and the lowest performance dropping rate. Particularly, our PD outperforms the state-of-the-art results by 10.80% on CIFAR100, 12.52% on miniImageNet and 18.83% on CUB200.

Conclusion

In this paper, we solve the few-shot incremental learning problems from two aspects. We first adopt a decoupled learning strategy to separate the learning of representations and classifiers, which effectively avoid knowledge forgetting in the backbone. Then, we propose a continually evolved classifier for few-shot incremental learning, which employs an adaptation module to update the classifier weights based on a global context of all sessions. To enable the learning of the adaptation module, we propose a pseudo incremental learning paradigm. Experiments on three datasets show that our method significantly outperforms the baselines and the state-of-the-art approaches.

Acknowledgement

This work was supported by Alibaba Group through Alibaba Innovative Research (AIR) Program and Alibaba-NTU Singaproe Joint Research Institute (JRI), Nanyang Technological University, Singapore. This research is also supported by the National Research Foundation, Singapore under its AI Singapore Programme (AISG Award No: AISG-RP-2018-003), and the MOE Tier-1 research grants: RG28/18 (S), RG22/19 (S) and RG95/20.

References

Appendix A Introduction

In our supplementary material, we present more details about the experiments in our paper.

Appendix B Detailed Result

In Section 5.4 Fig. 7, we have provided the comparison with the state-of-the-art methods in the form of line charts. Here, we present the detailed numbers in Table 3. The results show that our method significantly outperforms the baselines and achieves new state-of-the-art performance on all the three datasets.