Year: 2021

Abstract:
Continual learning requires the model to maintain the learned knowledge while learning from a non-i.i.d data stream continually. Due to the single-pass training setting, online continual learning is very challenging, but it is closer to the realworld scenarios where quick adaptation to new data is appealing. In this paper, we focus on online class-incremental learning setting in which new classes emerge over time. Almost all existing methods are replay-based with a softmax classifier. However, the inherent logits bias problem in the softmax classifier is a main cause of catastrophic forgetting while existing solutions are not applicable for online settings. To bypass this problem, we abandon the softmax classifier and propose a novel generative framework based on the feature space. In our framework, a generative classifier which utilizes replay memory is used for inference, and the training objective is a pair-based metric learning loss which is proven theoretically to optimize the feature space in a generative way. In order to improve the ability to learn new data, we further propose a hybrid of generative and discriminative loss to train the model. Extensive experiments on several benchmarks, including newly introduced task-free datasets, show that our method beats a series of state-of-the-art replay-based methods with discriminative classifiers, and reduces catastrophic forgetting consistently with a remarkable margin.

heading: 1 INTRODUCTION
text: Humans excel at continually learning new skills and accumulating knowledge throughout their lifespan. However, when learning a sequential of tasks emerging over time, neural networks notoriously suffer from catastrophic forgetting (McCloskey & Cohen, 1989) on old knowledge. This problem results from non-i.i.d distribution of data streams in such a scenario. To this end, continual learning (CL) (Parisi et al., 2019; Lange et al., 2019) has been proposed to bridge the above gap between intelligent agents and humans.
In common CL settings, there are clear boundaries between distinct tasks which are known during training. Within each task, a batch of data are accumulated and the model can be trained offline with the i.i.d data. Recently, online CL (Aljundi et al., 2019c;a) setting has received growing attention in which the model needs to learn from a non-i.i.d data stream in online settings. At each iteration, new data are fed into the model only once and then discarded. In this manner, task boundary is not informed, and thus online CL is compatible with task-free (Aljundi et al., 2019b; Lee et al., 2020) scenario. In real-world scenarios, the distribution of data stream changes over time gradually instead of switching between tasks suddenly. Moreover, the model is expected to quickly adapt to large amount of new data, e.g. user-generated content. Online CL meets these requirements, so it is more meaningful for practical applications. Many existing CL works deal with task-incremental learning (TIL) setting (Kirkpatrick et al., 2017; Li & Hoiem, 2018), in which task identity is informed during test and the model only needs to classify within a particular task. However, for online CL problem, TIL is not realistic because of the dependence on task boundary as discussed above and reduces the difficulty of online CL. In contrast, class-incremental learning (CIL) setting (Rebuffi et al., 2017) requires the model to learn new classes continually over time and classify samples over all seen classes during test. Thus, online CIL setting is more suitable for online data streams in real-world CL scenarios (Mai et al., 2021).
Most existing online CIL methods are based on experience replay (ER) (Robins, 1995; Riemer et al., 2019) strategy which stores a subset of learned data in a replay memory and uses the data in memory to retrain model thus alleviating forgetting. Recently, in CIL setting logits bias problem in the last fully connected (FC) layer, i.e. softmax classifier, is revealed (Wu et al., 2019), which is a main cause of catastrophic forgetting. In Figure 1a, we show in online CIL, even if ER is used, logits bias towards newly learned classes in the softamx classifier is still serious and the forgetting on old tasks is dramatic (See Figure 1b). Although some works (Wu et al., 2019; Belouadah & Popescu, 2019; Zhao et al., 2020) propose different methods to reduce logits bias, they all depend on task boundaries and extra offline phases during training so that not applicable for online CIL setting.
In this paper, we propose to tackle the online CIL problem without the softmax classifier to avoid logits bias problem. Instead, we propose a new framework where training and inference are both in a generative way. We are motivated by the insight that generative classifier is more effective in low data regime than discriminative classifier which is demonstrated by Ng & Jordan (2001). Although the conclusion is drawn on simple linear models (Ng & Jordan, 2001), similar results are also observed on deep neural networks (DNNs) (Yogatama et al., 2017; Ding et al., 2020) recently. It should be noticed that in online CIL setting the data is seen only once, not fully trained, so it is analogous to the low data regime in which the generative classifier is preferable. In contrast, the commonly used softmax classifier is a discriminative model.
Concretely, we abandon the softmax FC layer and introduce nearest-class-mean (NCM) classifier (Mensink et al., 2013) for inference, which can be interpreted as classifying in a generative way. The NCM classifier is built on the feature space on the top of previous network layers. Thanks to ER strategy, NCM classifier can utilize the replay memory for inference. As for training, inspired by a recent work (Boudiaf et al., 2020), which shows pair-based deep metric learning (DML) losses can be interpreted as optimizing the feature space from a generative perspective, we introduce MultiSimilarity (MS) loss (Wang et al., 2019) to obtain a good feature space for NCM classifier. Meanwhile, we prove theoretically that MS loss is an alternative to a training objective of the generative classifier. In this way, we can bypass logits bias.
To strengthen the model’s capable of learning from new data in complex data streams, we further introduce an auxiliary proxy-based DML loss (Movshovitz-Attias et al., 2017). Therefore, our whole training objective is a hybrid of generative and discriminative losses. During inference, we ignore the discriminative objective and classify with the generative NCM classifier. By tuning weight of the auxiliary loss, our method can work well in different data streams.
In summary, our contributions are as follows:
1. We make the first attempt to avoid logits bias problem in online CIL setting. In our generative framework, a generative classifier is introduced to replace softmax classifier for inference and for training, we introduce MS loss which is proven theoretically to optimize the model in a generative way.
2. In order to improve the ability of MS loss to learn from new data, we further introduce an auxiliary loss to achieve a good balance between retaining old knowledge and learning new knowledge.
3. We conduct extensive experiments on four benchmarks in multiple online CIL settings, including a new task-free setting we design for simulating more realistic scenarios. Empirical results demonstrate our method outperforms a variety of state-of-the-art replay-based methods substantially, especially alleviating catastrophic forgetting significantly.

heading: 2 RELATED WORK
text: Current CL methods can be roughly divided into three categories: which are regularization, parameter isolation and replay-based respectively (Lange et al., 2019). Regularization methods retain the learned knowledge by imposing penalty constraints on model’s parameters (Kirkpatrick et al., 2017) or outputs (Li & Hoiem, 2018) when learning new data. They work well in TIL setting but poor in CIL setting (van de Ven & Tolias, 2018). Parameter isolation methods assign a specific subset of model parameters, such as network weights (Mallya & Lazebnik, 2018) and sub-networks (Fernando et al., 2017) to each task to avoid knowledge interference and thus the network may keep growing. This type of method is mainly designed for TIL as task identity is usually necessary during test. The mainstream of Replay-based methods is ER-like (Rebuffi et al., 2017), which stores a subset of old data and retrains it when learning new data to prevent forgetting of old knowledge. In addition, generative replay method trains a generator to replay old data approximately (Shin et al., 2017).
In the field of online CL, most of methods are on the basis of ER. Chaudhry et al. (2019b) first explored ER in online CL settings with different memory update strategies. Authors suggested ER method should be regarded as an important baseline as in this setting it is more effective than several existing CL methods, such as A-GEM (Chaudhry et al., 2019a). GSS (Aljundi et al., 2019c) designs a new memory update strategy by encouraging the divergence of gradients of samples in memory. MIR (Aljundi et al., 2019a) is proposed to select the maximally interfered samples from memory for replay. GMED (Jin et al., 2020) edits the replay samples with gradient information to obtain samples likely to be forgotten, which can benefit the replay in the future. Mai et al. (2021) focus on online CIL setting and adopt the notion of Shapley Value to improve the replay memory update and sampling. All of the above methods are replay-based with softmax classifier. A contemporary work (Lange & Tuytelaars, 2020) proposes CoPE, which is somewhat similar to our method. CoPE replaces softmax classifier with a prototype-based classifier which is non-parametric and updated using features of data samples. However, the loss function of CoPE is still discriminative and the way to classify is analogous to softmax classifier.
Apart from the above ER based methods, Zeno et al. (2018) propose an online regularization method, however it performs very badly in online CL settings (Jin et al., 2020). Lee et al. (2020) propose a parameter isolation method in which the network is dynamically expanded and a memory for storing data is still required. Therefore, the memory usage is not fixed and potentially unbounded.
A recent work (Yu et al., 2020) proposes SDC, a CIL method based on DML and NCM classifier. However, SDC requires an extra phase to correct semantic drift after training each task. This phase depends on task boundaries and the accumulated data of a task, which is not applicable for online CIL. In contrast, our method is based on ER and classifies with replay memory and thus need not correct the drift.

heading: 3 ONLINE CLASS-INCREMENTAL LEARNING WITH A GENERATIVE FRAMEWORK

heading: 3.1 PRELIMINARIES AND MOTIVATIONS

heading: 3.1.1 ONLINE CLASS-INCREMENTAL LEARNING
text: CIL setting has been widely used in online CL literature, e.g. (Aljundi et al., 2019a; Mai et al., 2021), and a softmax classifier is commonly used. A neural network f(·;θ) : X → Rd parameterized by θ encodes data samples x ∈ X into a d-dimension feature f(x) on which an FC layer g outputs logits for classification: o = Wf(x) + b. At each iteration, a minibatch of data Bn from a data stream S
arrives and the whole model (f, g) is trained on Bn only once. The training objective is cross-entropy (CE) loss:
LCE = − C̃∑ c=1 t:c log ŷ:c, ŷ:c = eo:c∑C̃ c=1 e o:c (1)
where C̃ is the number of classes seen so far. t is one-hot label of x and the subscript :c denotes the c-th component. The new classes from S emerge over time. The output space of g is the number of seen classes and thus keeps growing. At test time, the model should classify over all C classes seen.

heading: 3.1.2 EXPERIENCE REPLAY FOR ONLINE CONTINUAL LEARNING
text: ER makes two modifications during online training: (1) It maintains a replay memoryM with limited size which stores a subset of previously learned samples. (2) When a minibatch of new data Bn is coming, it samples a minibatch Br fromM and uses Bn ∪ Br to optimize the model with one SGD-like step. Then it updatesM with Bn. Recent works, e.g. (Aljundi et al., 2019a; Mai et al., 2021) regard ER-reservoir as a strong baseline, which combines ER with reservoir sampling (Vitter, 1985) for memory update and random sampling for Br. See Chaudhry et al. (2019b) for more details about it.

heading: 3.1.3 LOGITS BIAS IN SOFTMAX CLASSIFIER
text: Some recent works (Wu et al., 2019; Belouadah & Popescu, 2019; Zhao et al., 2020) show in CIL scenarios, even with replay-based mechanism the logits outputted by model always have a strong bias towards the newly learned classes, which leads to catastrophic forgetting actually. In preliminary experiments, we also observe this phenomenon in online CIL setting. We run ER-reservoir baseline on 5-task Split CIFAR10 (each task has two disjoint classes) online CIL benchmark. In Figure 1a, we display the average logits of each already learned tasks over samples in test data after learning each task. The model outputs much higher logits on the new classes (of the task just learned) than old classes.
Following (Ahn & Moon, 2020), we examine the CE loss in Eq (1), the gradient of LCE w.r.t logit o:c of class c is ŷ:c − I[t:c = 1]. Thus, if c is the real label y, i.e. t:c = 1, the gradient is non-positive and model is trained to increase o:c, otherwise the gradient is non-negative and model is trained to decrease o:c. Therefore, logits bias problem is caused by the imbalance between the number of samples of the new classes and that of the old classes with a limited size ofM. As mentioned in Section 1, existing solutions (Wu et al., 2019; Belouadah & Popescu, 2019; Zhao et al., 2020) designed for conventional CIL need task boundaries to conduct extra offline training phases and even depend on the accumulated data of one task. They are not applicable for online CIL setting where task boundaries are not informed or even do not exist in task-free scenario.

heading: 3.2 INFERENCE WITH A GENERATIVE CLASSIFIER
text: Proposed generative framework is based on ER strategy, and aims to avoid the intrinsic logits bias problem by removing the softmax FC layer g and build a generative classifier on the feature space Z : z = f(x). If the feature z is well discriminative, we can conduct inference with samples in M instead of a parametric classifier which is prone to catastrophic forgetting (Rebuffi et al., 2017). We use NCM classifier firstly suggested by Rebuffi et al. (2017) for CL and show it is a generative model. We use Mc to denote the subset of class c of M. The class mean µc is computed by µMc = 1 |Mc| ∑ x∈Mc f(x). During inference, the prediction for x ∗ is made by:
y∗ = argmin c ‖f(x∗)− µMc ‖2 (2)
In fact, the principle of prediction in Eq (2) is to find a Gaussian distribution N (f(x∗)|µMc , I) with the maximal probability for x∗. Therefore, assuming the conditional distribution p(z|y = c) = N (z|µMc , I) and the prior distribution p(y) is uniform, NCM classifier virtually deals with p(y|z) by modeling p(z|y) in a generative way. The inference way is according to Bayes rule: argmax p(y|x∗) = argmax p(f(x∗)|y)p(y). The assumption about p(y) simplifies the analysis
and works well in practice. In contrast, softmax classifier models p(y|x∗) in a typical discriminative way.
As discussed above, online CIL is in a low data setting where generative classifiers are preferable compared to discriminative classifiers (Ng & Jordan, 2001). Moreover, generative classifiers are more robust to continual learning (Yogatama et al., 2017) and imbalanced data settings (Ding et al., 2020). At each iteration, Bn ∪Br is also highly imbalanced. Considering these results, we hypothesis generative classifiers are promising for online CIL problem. It should be noted our method only models a simple generative classifier p(z|y) on the feature space, instead of modeling p(x|y) on the input space using DNNs (Yogatama et al., 2017), which is time-consuming and thus is not suitable for online training.

heading: 3.3 TRAINING WITH A PAIR-BASED METRIC LEARNING LOSS FROM A GENERATIVE PERPECTIVE
text: To train the feature extractor f(θ) we resort to DML losses which aim to learn a feature space where the distances represent semantic dissimilarities between data samples. From the perspective of mutual information (MI), Boudiaf et al. (2020) theoretically show the equivalence between CE loss and several pair-based DML losses, such as contrast loss (Hadsell et al., 2006) and Multi-Similarity (MS) loss (Wang et al., 2019). The DML losses maximize MI between feature z and label y in a generative way while CE loss in a discriminative way, which motivates us to train f(θ) with a pair-based DML loss to obtain a good feature space Z for the generative classifier. Especially, we choose the MS loss as a training objective. MS loss is one of the state-of-the-art methods in the field of DML. Wang et al. (2019) point out pair-based DML losses can be seen as weighting each feature pair in the general pair weighting framework. As MS loss requires the feature f(x) to be `2-normalized first, from now on, we use zi to denote the `2-normalized feature of xi and a feature pair is represented in the form of inner product Sij := zTi zj . To weight feature pairs better, MS loss is proposed to consider multiple types of similarity. MS loss on a dataset D is formulated as follows:
LMS(D) = 1
|D| |D|∑ i=1 { 1 α log[1 + ∑ j∈Pi e−α(Sij−λ)] + 1 β log[1 + ∑ j∈Ni eβ(Sij−λ)] }
(3)
where α, β and λ are hyperparameters and Pi and Ni represent the index set of positive and negative samples of xi1 respectively. MS loss also utilizes the hard mining strategy to filter out too uninformative feature pairs, i.e. too similar positive pairs and too dissimilar negative pairs:
Pi = {j|Sij < max yk 6=yi Sik + } Ni = {j|Sij > min yk=yi Sik − } (4)
where is another hyperparameter in MS loss. At each iteration we use MS loss on the union of new samples and replay samples LMS(Bn ∪ Br) to train the model. The sampling of Br and update of M are the same as ER-reservoir. To show the connection between LMS and the generative classifier in Eq (2), we conduct some theoretical analyses.
Proposition 1. Assume dataset D = {(xi, yi)}ni=1 is class-balanced and has C classes each of which has n0 samples. For a generative model p(z, y), assume p(y) actually obeys the uniform distribution and p(z|y = c) = N (z|µDc , I) where µDc = 1n0 ∑n i=1 ziI[yi = c]. For MS loss assume hard mining in Eq (4) is not employed. Then we have:
LMS c ≥ LGen−Bin (5)
where c ≥ stands for upper than, up to an additive constant c and LGen−Bin is defined in the following:
LGen−Bin = − 1
n n∑ i=1 log p(zi|y = yi) + 1 nC n∑ i=1 C∑ c=1 log p(zi|y = c) (6)
1The positive samples have the same labels as xi while the negative samples have different labels from xi.
The proof of Proposition 1 is in Appendix. Proposition 1 shows LMS is an upper bound of LGen−Bin and thus is an alternative to minimizing LGen−Bin. The first term of LGen−Bin aims to minimize the negative log-likelihood of the class-conditional generative classifier, while the second term maximizes the conditional entropy H(Z|Y ) of labels Y and features Z. It should be noticed LGen−Bin depends on modeling p(z|y). With uniform p(y), classifying using p(z|y) equals to classifying using p(z, y), and H(Z|Y ) is equivalent to H(Z, Y ), which can be regarded as a regularizer against features collapsing. Thus, LGen−Bin actually optimizes the model in a generative way. The assumptions in Proposition 1 are similar with those in Section 3.2 about NCM classifier. The difference lies in that NCM classifier uses {µMc } computed on replay memoryM to approximate {µDc }. Therefore, Proposition 1 reveals that MS loss optimizes the feature space in a generative way and it models p(z|y) for classification which is consistent with the NCM classifier. The real class means {µDc } depend on all training data and change with the update of f(θ) so that are intractable in online settings. MS loss can be efficiently computed as it does not depend on {µDc } thus the model can be trained efficiently. During inference, we use approximate class means µMc to classify. In Figure 1b, on 5-task Split CIFAR10 benchmark, we empirically show compared to softmax classifier, on old tasks, our method achieves much higher accuracy and much lower forgetting, which implies MS loss is an effective objective to train the model f and class mean µMc of replay memory is a good approximation of µDc .
With discriminative loss like CE loss, the classifier models a discriminative model p(y|z). Therefore, if training with discriminative loss and inference with NCM classifier based on the generative model p(z|y), we can not expect to obtain good results. In the next section, experiments will verify this conjecture. In contrast, the way to train and inference are coincided in proposed generative framework.

heading: 3.4 A HYBRID GENERATIVE/DISCRIMINATIVE LOSS
text: However, when addressing classification tasks, generative classifier has natural weakness, since modeling joint distribution p(x, y) is much tougher than modeling conditional distribution p(y|x) for NNs. Moreover, in preliminary experiments, we found if only trained with MS loss, the NCM classifier’s performance degenerates as the expected number of classes in Bn at each iteration increases. This phenomenon is attributed to the inadequate ability to learn from new data, instead of catastrophic forgetting. We speculate because the size of Bn is always fixed to a small value (e.g. 10) in online CIL settings, the number of positive pairs in Bn decreases as the expected number of classes increases.
To remedy this problem, we take advantage of discriminative losses for fast adaptation in online setting. To this end, we introduce Proxy-NCA (PNCA) (Movshovitz-Attias et al., 2017), a proxybased DML loss, as an auxiliary loss. For each class, PNCA loss maintains “proxies” as the real feature to utilize the limited data in a minibatch better, which leads to convergence speed-up compared to pair-based DML losses. Concretely, when a new class c emerges, we assign one trainable proxy pc ∈ Rd to it. PNCA loss is computed as:
LPNCA(D) = − 1 |D| ∑
(x,y)∈D
log e−‖f(x)−py‖ 2 2∑C̃
c=1 e −‖f(x)−pc‖22
(7)
Movshovitz-Attias et al. (2017) suggest all proxies have the same norm NP and all features have the norm NF . The latter satisfies as in MS loss the feature is `2-normalized, i.e. NF = 1. We also set NP = 1 by normalizing all proxies after each SGD-like update. In this way, LPNCA is equivalent to a CE loss with `2-normalized row vectors of W and without bias b, and thus we use PNCA instead of CE loss to keep utilizing the normalized features of MS loss. Our full training objective is a hybrid of generative and discriminative losses:
LHybrid = LMS + γLPNCA (8) where γ is a hyperparameter to control the weight of LPNCA. In general, generative classifiers have a smaller variance but higher bias than discriminative classifiers, and using such a hybrid loss can achieve a better bias-variance tradeoff (Bouchard & Triggs, 2004). Thus we think introducing the discriminative loss LPNCA can reduce the bias of model so that boost the ability to learn from new data.
It should be noticed we train the model with LHybrid(Bn ∪Br), while we only use NCM classifier in Eq (2) for inference. In all experiments, we set α = 2, β = 50, = 0.1 following Wang et al. (2019)
1 2 3 4 5 6 7 8 9 10 Task Number
10
20
30
40
50
Av er
ag e
ac cu
ra cy
Split CIFAR-100 (10-task) fine-tune ER-reservoir A-GEM GSS-Greedy MIR GMED-ER GMED-MIR CoPE Ours
1 2 3 4 5 6 7 8 9 10 Task Number
10
20
30
40
50 Split miniImageNet (10-task)
Figure 3: Average Accuracy on already learned task during training.
and λ = 0.5 which always works well in online CIL settings. We only need to tune hyperparemeters γ in Eq (8) for different experiment settings.

heading: 4 EXPERIMENTS

heading: 4.1 EXPERIMENT SETUP
text: Datasets First, we conduct experiments on Split datasets which are commonly used in CIL and online CIL literature. On Split MNIST and CIFAR10, the datasets are split into 5 tasks each of which comprises 2 classes. On CIFAR100 and miniImageNet with 100 classes, we split them into 10 or 20 tasks. The number of classes in each task is 10 or 5 respectively. For MNIST we select 5k samples for training following Aljundi et al. (2019a) and we use full training data for other datasets. To simulate a task-free scenario, task boundaries are not informed during training (Jin et al., 2020).
To conduct a thorough evaluation in task-free scenarios, we design a new type of data streams. For a data stream with C classes, we assume the length of stream is n and n0 = n/C. We denote pc(t) as the occurrence probability of class c at time step t and assume pc(t) ∼ N (t|(2c− 1)n0/2, n0/2). At each time step t, we calculate p(t) = (p1(t), . . . , pC(t)) and normalize p(t) as the parameters of a Categorical distribution from which a class index ct is sampled. Then we sample one data of class ct without replacement. In this setting, data distribution changes smoothly and there is no notion of task. We call such data streams as Smooth datasets. To build Smooth datasets, we set n = 5k on CIFAR10 and n = 40k on CIFAR100 and miniImageNet, using all classes in each dataset. For all datasets, the size of minibatch Bn is 10. In Figure 2 we plot the probability distribution on class at each time step in the data stream generation process for Split CIFAR10 and Smooth CIFAR10. For better comparison, we set the length of data stream of two datasets both 5k. Split CIFAR10 has clear task boundaries and within one task the distribution on class is unchanged and uniform. However, On Smooth CIFAR10, the distribution on class keeps changing and there is no notion of task.
Baselines We compare our method against a series of state-of-the-art online CIL methods, including: ER-reservoir, A-GEM, GSS, MIR, GMED, CoPE and ASER. We have briefly introduced them in Section 2. Specially, we use GSS-greedy and ASERµ which are the best variants in the corresponding paper. For GMED, we evaluate both GMED-ER and GMED-MIR. We also evaluate fine-tune baseline without any CL strategy. For all baselines and our method, the model is trained with 1 epoch, i.e. online CL setting. In addition, the performances of i.i.d online and i.i.d offline are also provided, by training the model 1 and 5 epochs respectively on i.i.d data streams. We reimplement all baselines except ASERµ, whose results are from the original paper. Model Following Aljundi et al. (2019a), the model f is a 2-layer MLP with 400 hidden units for MNIST and a reduced ResNet18 for other datasets. For baselines with ER strategy, the size of replay minibatch Br is always 10. The budget of memoryM is 500 on MNIST and 1000 on others. We use a relatively small budget |M| to mimic a practical setting. All models are optimized by SGD. The single-head evaluation is always used for CIL. More details about datasets, hyperparameter selection and evaluation metrics are in Appendix.
4.2 MAIN RESULTS ON Split DATASETS
On Split datasets, we use Average Accuracy and Average Forgetting after training all tasks (Chaudhry et al., 2019b) for evaluation, which are reported in Table 1 and Table 2 respectively. For each metric, we report the mean of 15 runs and the 95% confidence interval.
In Table 1, we can find our method outperforms all baselines on all 6 settings. The improvement of our method is significant except on MNIST, where GMED-MIR is competitive with our method. An interesting phenomenon is all existing methods do not have a substantial improvement over ER-reservoir on CIFAR100 and miniImageNet, except ASER. We argue for online CIL problem, we should pay more attention to complex settings. Nevertheless, our method is superior to ASER obviously, especially on CIFAR10 and miniImageNet. Table 2 shows the forgetting of our method is far lower than other methods based on the softmax classifier, except on MNIST. Figure 3 shows our method is almost consistently better than all baselines during the whole learning processes. More results with various memory sizes can be found in Appendix.
Ablation Study We also conduct ablation study about training objective and classifier in Table 4. The ER-reservoir corresponds to the first row and our method corresponds to the last row. Firstly, we find for ER-reservoir, replacing softmax classifier with NCM classifier makes a substantial improvement on CIFAR10. However, it has no effect on more complex CIFAR100 (row 1&2). Secondly, only using MS loss works very well on CIFAR10 while on CIFAR100 poor ability to learn from new data limits its performance (row 3&6). Lastly, when hybrid loss is used, the NCM classifier is much better than proxy-based classifier (row 5&6), and MS loss is critical for NCM classifier (row 4&6). Note that hybrid loss does not outperform MS loss much on Split-CIFAR10. This is because in Split-CIFAR10, a minibatch of new data contains a maximum of two classes, and thus the positive pairs are enough fo MS loss to learn new knowledge well. These results verify our statement in Section 3.2.
Comparison with Logits Bias Solutions for Conventional CIL Setting Although existing CIL methods to alleviate logits bias are not applicable for online CIL settings as task boundaries are necessary, after being modified in some ways they can be adapted to online CIL. To better reflect the contribution of our method, we adapt iCaRL (Rebuffi et al., 2017) and BiC (Wu et al., 2019) to online CIL and compare modified iCaRL and modified BiC with our method in Table 3. iCaRL replaces softmax classifier with NCM classifier and BiC uses a linear bias correction layer to reduce logits bias. and iCaRL is modified in the following way: at each iteration, we minimize binary CE loss used by iCaRL which encourages the model to mimic the outputs for all learned classes of the
Methods MNIST(5-task) CIFAR10 (5-task) CIFAR100 (20-task) miniImageNet (20-task)
modified iCaRL 34.58 ±1.18
29.77 ±0.91
5.38 ±0.26
7.16 ±0.33
modified BiC 83.33 ±1.35
43.65 ±2.50
8.72 ±0.30
7.91 ±0.55
Ours 88.79±0.26 51.84 ±0.91
13.65 ±0.35
15.15 ±0.36
Table 3: The comparison between modified iCaRL, modified BiC and our method (Ours) on Split datasets.
Training Inference CIFAR10 CIFAR100 CE loss Softmax (Dis) 39.88±1.52 8.95±0.26 CE loss NCM (Gen) 44.46±0.95 8.96±0.38 MS loss NCM (Gen) 51.72±1.02 9.99±0.32 PNCA loss NCM (Gen) 41.91±1.78 9.31±0.58 Hybrid loss Proxy (Dis) 48.16±1.21 7.02±0.75 Hybrid loss NCM (Gen) 51.84±0.91 13.65±0.35
Table 4: Ablation study on Split CIFAR10 and 20- task Split CIFAR100. We show the performances of different combinations of losses and inference ways. Dis: Discriminative, Gen: Generative.
old model after the last iteration. We use reservoir sampling for memory update. NCM classifier is used for inference. For modified BiC, we use the linear bias correction layer of BiC to correct the logits for all learned classes only before test as task boundaries are unavailable in online CIL setting. As shown in Table 3, modified iCaRL performs very badly and the performances of modified BIC are much worse than our method. These results imply adapting existing methods to online setting can not alleviate logits bias effectively for online CIL. Therefore, our method makes a substantial contribution for online CIL.
Time Comparison In Figure 4a, we report the training time of different methods. The training time of our method is only a bit higher than ER-reservoir.
Most baselines, such as GSS, MIR, and GMED, improve ER-reservoir by designing new memory update and sampling strategies which depend on extra gradient computations and thus are timeconsuming. The inference costs of softmax classifier and our NCM classifier are displayed in Figure 4b. We can find the extra time of NCM to compute the class means is (about 3%) slight, as the size of memory is limited.
4.3 RESULTS ON TASK-FREE Smooth DATASETS
In newly designed task-free Smooth datasets, the new classes emerge irregularly and the distribution on class changes at each time step. In Table 5, we compare our method with several baselines on three smooth datasets. The metric is final accuracy after learning the whole data stream. We can find these datasets are indeed more complex as fine-tune can only classify correctly on the last class, which is due to the higher imbalance of data streams. For this reason, baselines such as ER-reservoir and MIR degrade obviously compared with split datsets. However, our method performs best consistently.

heading: 5 CONCLUSION
text: In this work, we tackle with online CIL problem from a generative perspective to bypass logits bias problem in commonly used softmax classifier. We first propose to replace softmax classifier with a generative classifier. Then we introduce MS loss for training and prove theoretically that it optimizes the feature space in a generative way. We further propose a hybrid loss to boost the model’s ability to learn from new data. Experimental results show the significant and consistent superiority of our method compared to existing state-of-the-art methods.

heading: A PROOFS

heading: A.1 PROPOSITION 1
text: Proof. For simplicity, we ignore the coefficient 1n both in LMS and LGen−Bin in the proof. We denote the two parts in the summation of LMS as L+MS and L − MS respectively, i.e.:
L+MS = n∑ i=1 1 α log[1 + ∑ j∈Pi e−α(Sij−λ)]
L−MS = n∑ i=1 1 β log[1 + ∑ j∈Ni eβ(Sij−λ)]
(9)
Without hard mining, for L+MS we have:
L+MS = n∑ i=1 1 α log[1 + ∑ j:yj=yi e−α(Sij−λ)]
≥ n∑ i=1 1 α log[ ∑ j:yj=yi e−α(Sij−λ)]
c ≥ n∑ i=1 1 α [ 1 n0 ∑ j:yj=yi log e−α(Sij−λ)]
B Jensen’s inequality
= n∑ i=1 1 n0 [ ∑
j:yj=yi
−(Sij − λ)]
c = − n∑ i=1 1 n0 ∑ yj=yi Sij
(10)
where c= stands for equal to, up to an additive constant. For L−MS we can write:
L−MS = n∑ i=1 1 β log[1 + ∑ j:yj 6=yi eβ(Sij−λ)]
≥ n∑ i=1 1 β log[ ∑ j:yj 6=yi eβ(Sij−λ)]
c ≥ n∑ i=1 1 β [
1 n0(C − 1) ∑
j:yj 6=yi
log eβ(Sij−λ)]
B Jensen’s inequality
= n∑ i=1
1 n0(C − 1) ∑
j:yj 6=yi
Sij
(11)
According to Eq (10) and Eq (11), we have:
LMS c ≥ n∑ i=1 { − 1 n0 ∑ j:yj=yi Sij + 1 (C − 1)n0 ∑ j:yj 6=yi Sij }
(12)
Now we consider LGen−Bin. Firstly, it can be written:
LGen−Bin c = n∑ i=1 { − log p(zi|y = yi)
+ 1
C − 1 C∑ c=1,c 6=yi log p(zi|y = c) } (13)
For convenience, we denote the features of data samples whose labels are c as {zci} n0 i=1. For the first part in the right hand of Eq (13), we have:
n∑ i=1 − log p(zi|y = yi)
c = 1
2 n∑ i=1 ‖zi − µDc ‖22 B p(z|y = c) = N (z|µDc , I)
= 1
2 C∑ c=1 n0∑ i=1 ‖zci − µDc ‖22
= 1
2 C∑ c=1 n0∑ i=1 { ‖zci‖22 − 2zTciµ D c + ‖µDc ‖22 } c = 1
2 C∑ c=1 { n0∑ i=1 −2n0‖µDc ‖22 + n0‖µDc ‖22 } B ‖z‖22 = 1
= 1
2 C∑ c=1 n0∑ i=1 −n0‖µDc ‖22
= 1
2 C∑ c=1 n0∑ i=1 n0∑ j=1 − 1 n0 zTcizcj
=− n∑ i=1 ∑ j:yj=yi 1 2n0 Sij
(14)
Keep in mind that the mean of class c µDc = 1 n0 ∑n0 i=1 zci . For the second part in the right hand of Eq (13), we have: n∑ i=1 C∑ c=1,c 6=yi log p(zi|y = c)
= 1
2 n∑ i=1 C∑ c=1,c6=yi −‖zi − µDc ‖22
= 1
2 n∑ i=1 C∑ c=1,c6=yi { − ‖zi‖22 + 2zTi µDc − ‖µDc ‖22 } c = 1
2 n∑ i=1 C∑ c=1,c6=yi 2zTi µ D c − (C − 1)n0 C∑ c=1 ‖µDc ‖22 B ‖z‖22 = 1
= 1
2 n∑ i=1 C∑ j:yj 6=yi 2 n0 zTi zj − C − 1 n0 C∑ c=1 n0∑ i=1 n0∑ j=1 zTcizcj
= n∑ i=1 { ∑ j:yj 6=yi 1 n0 Sij − ∑ j:yj=yi C − 1 2n0 Sij }
(15)
According to Eq (14) and Eq (15), we have:
LGen−Bin c = n∑ i=1 { − 1 n0 ∑ j:yj=yi Sij + 1 (C − 1)n0 ∑ j:yj 6=yi Sij }
(16)
According to Eq (12) and Eq (16), we can obtain:
LMS c ≥ LGen−Bin (17)

heading: B DETAILS ABOUT EXPERIMENT SETUP

heading: B.1 SPLIT DATASETS
text: In Table 6 we show the detailed statistics about Split datasets. On MNIST (LeCun et al., 1998), we randomly select 500 samples of the original training data for each class as training data stream, following previous works (Aljundi et al., 2019a;c; Jin et al., 2020). On CIFAR10 and CIFAR100 (Krizhevsky et al., 2009), We use the full training data from which 5% samples are regarded as validation set. The original miniImageNet dataset is used for meta learning (Vinyals et al., 2016) and 100 classes are divided into 64 classes, 16 classes, 20 classes respectively for meta-training, meta-validation and meta-test respectively. We merge all 100 classes to conduct class-incremental learning. There are 600 samples per class in miniImageNet. We divide 600 samples into 456 samples, 24 samples and 120 samples for training, validation and test respectively. We do not adopt any data augmentation strategy.

heading: B.2 SMOOTH DATASETS
text: For a data stream with C classes, we assume the length of stream is N and n0 = Nc . We denote pc(t) as the occurrence probability of class c at time step t and assume pc(t) ∼ N (t| (2c−1)n02 , n0 c ). At each time step t, we calculate p(t) = (p1(t), ..., pC(t)) and normalize p(t) as the parameters of a Categorical distribution from which a class index ct is sampled. Then we sample one data of class ct without replacement. In this setting, data distribution changes smoothly and there is no notion of task. We call such data streams as Smooth datasets.
Here we show the characteristics of Smooth datasets in detail. In Table 7, we list the detailed statistics of Smooth datasets. Due to the randomness in the data stream generation process, the number of
samples of each class is slightly imbalanced. On CIFAR100 and miniImageNet we set the mean number of samples of each class n0 = 400 to avoid invalid sampling when exceeding the maximum number of sample of one class in the original training set. The last rows of Table 7 show the range of number of samples of each classes in our experiments. For example, in 15 repeated runs, 15 different Smooth CIFAR10 data streams are established. The number of samples of each class is in the interval [464, 536]. It should be emphasized that in all experiments we use the same random seed to obtain the identical 15 data streams for fair comparison.
Some existing works (Zeno et al., 2018; Lee et al., 2020) also experiment on task-free datasets where a data stream is still divided into different tasks but the switch of task is gradual instead of abrupt. In fact, in their settings, task switching only occurs in a part of time, so that in the left time the distribution of data streams is still i.i.d. In contrast, in our Smooth datasets the distribution changes at the class level which simulates task-free class-incremental setting. In addition, the distribution of data streams is never i.i.d, which can reflect real-world CL scenarios better.
In Figure 5, we plot the curves of training loss of ER-reservoir on Split CIFAR10 and Smooth CIFAR10. When a new task emerges (each task consists of 100 iterations), the loss on Split CIFAR10 increases dramatically. Thus some methods can detect the change of loss to inference the task boundaries although they are not informed and conduct additional offline training phase (Aljundi et al., 2019b). However, such a trick is not applicable on Smooth datasets therefore only the real online CL methods can work.

heading: B.3 HYPERPARAMETER SELECTION
text: In our method, although there are several hyperparameters in LMS and LPNCA, we only need to tune γ which is the weight of LPNCA in LHybrid. The value of other hyperparameters in LHybrid is fixed as stated in the main text. We select γ from [0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0]. Especially, γ = 0 makes LHybrid become LMS . We follow previous works to use SGD optimizer in all experiments. However, we find compared to CE loss, a wider range of learning rate η should be searched in for DML losses. Previous works are based on CE loss and always set η = 0.05 or η = 0.1 (Aljundi et al., 2019c;a; Jin et al., 2020; Mai et al., 2021). We find the optimal η for LHybrid is often larger than 0.1. However, when a larger η (e.g. 0.2 on MNIST and CIFAR10) is used, baselines based on CE loss will degrade obviously because of the unstable results over multiple runs. Thus, for baselines we select η from [0.05, 0.1, 0.15, 0.2]. For our
method, we select η from [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5]. The hyperparameters of our method are displayed in Table 8.

heading: B.4 EVALUATION METRICS
text: Following previous online CL works (Aljundi et al., 2019a; Mai et al., 2021), we use Average Accuracy and Average Forgetting (Chaudhry et al., 2019b) on Split datasets after training all T tasks. Average Accuracy evaluates the overall performance and Average Forgetting measures how much learned knowledge has been forgetten. Let ak,j denote the accuracy on the held-out set of the j-th task after training the model on the first k tasks. For a dataset comprised of T tasks, the Average Accuracy is defined as follows:
AT = 1
T T∑ j=1 aT,j (18)
and Average Forgetting can be written as:
fTj = max l∈{1,...,T−1} al,j − aT,j ,∀j < T (19)
FT = 1
T − 1 T−1∑ j=1 fTj (20)
We report Average Accuracy and Average Forgetting in the form of percentage. It should be noted that a higher Average Accuracy is better while a lower Average Forgetting is better.
On Smooth datasets, as there is no notion of task, we evaluate the performance with the accuracy on the whole held-out set after finishing training the whole training set.

heading: B.5 CODE DEPENDENCIES AND HARDWARE
text: The Python version is 3.7.6. We use the PyTorch deep learning library to implement our method and baselines. The version of PyTorch is 1.7.0. Other dependent libraries include Numpy (1.17.3), torchvision (0.4.1), matplotlib (3.1.2) and scikit-learn (0.22). The CUDA version is 10.2. We run all experiments on 1 NVIDIA RTX 2080ti GPU. We will publish our codes once the paper is accepted.

heading: C MORE EXPERIMENTAL RESULTS
text: C.1 EFFECT OF PROXY-NCA LOSS WEIGHT γ
In Table 6, we show the effect of Proxy-NCA loss weight γ on split datasets. We can find on MNIST and CIFAR10 where the number of classes is relatively small, although the best results are obtained with γ = 0.1, we can have competitive results with γ = 0. In other words, only using MS loss is effective enough. However, on CIFAR100 and miniImageNet, as discussed in main text, the expected number of classes in each minibatch is larger which reduces the probability of occurrence of positive pair so that limits the learning ability of pair-based MS loss. At this time, it is necessary to introduce auxiliary PNCA loss. When γ is larger than 1, the performance begins to degrade, which implies that excessively focusing on discriminative PNCA loss will affect the performance of the generative NCM classifier.

heading: ER-reservoir

heading: C.2 RESULTS WITH DIFFERENT MEMORY SIZES
text: In Table 9 and Table 10, we report the performance of our method and all baselines compared in main text on Split CIFAR100 and miniImageNet with 2k memory size. Our method performs best in all settings and the improvements are obvious, which is similar with the results in 1k memory size settings reported in Table 1-2 of main text. We also report Average Accuracy of ER-reservoir and our method on valid set with a various of memory sizes. Our method outperforms ER-reservoir consistently which shows broad applicability of our method. The improvements are relatively small when memory size is 500 on CIFAR100 and miniImageNet, which is due to the fact that when size of replay memoryM is too small (5 samples per class on average), class mean µMc cannot approximate the real class mean µDc well and thus proposed NCM classifier degrades.

heading: C.3 COMPARISON WITH TRIPLET LOSS
text: Yu et al. (2020) proposes SDC method for conventional CIL based on NCM classifier and another pair-based DML loss, triplet loss (Hoffer & Ailon, 2015). As discussed in Related Work of main text, SDC is not applicable for online CIL. To further clarify our contribution given this work, we evaluate the performance of NCM classifier after training the model with the hybrid objective LTriplet + γLPNCA, where LTriplet represents triplet loss. Please see Hoffer & Ailon (2015) and (Yu et al., 2020) for details about LTriplet. We report the results of the hybrid objective involving triplet loss and compare it with our hybrid loss (LMS + γLPNCA) in Table 11. We can find our proposed loss is superior to LTriplet + γLPNCA consistently. In addition to replace softmax classifier with NCM classifier for online CIL problem, our contributions mainly reflect in introducing a hybrid of MS loss and PNCA loss in the view of training the generative NCM classifier. We believe the above results show MS loss is critical for online CIL, and introducing MS loss is not a trivial contribution, even if given the SDC work (Yu et al., 2020).

Review summaries:
The paper proposes a hybrid loss of generative classification by NCM as a form of Multi-Similarity (MS) loss (Wang et al., 2019) and discriminative classification by Proxy-NCA (Movshovits-Attias et al., 2017). The paper contains a theoretical argument that the MS loss upper-bounds the 'Gen-Bin loss', which is a generative classification model. The hybrid loss shows decent gains in 'average accuracy' (Table 1) and large gain in 'forgetting' (Table 2) in the experiments with multiple datasets including MNIST, CIFAR-10/100, miniImageNet with smaller computational complexity than the prior arts (Fig. 4).

To address the problem of logits bias in class-incremental learning with deep neural networks, this paper proposes to replace the typically used softmax output layer by a nearest-mean classifier (on the feature space), which can be interpreted as a generative classifier. To train the feature attractor in an online setting (i.e., without reliance on task boundaries), the paper proposes a hybrid loss consisting of a multi-similarity loss (which can be interpreted as an approximate generative objective) and an auxiliary “proxy” loss. The paper reports substantial performance improvements on a number of computer vision benchmark (including ones with natural images) over a selection of existing methods.  Additionally, the paper proposes a new “smooth dataset” benchmark for online class-incremental learning, whereby the transitions between classes are smooth rather than based on abrupt task transitions. 

This work develops a novel generative framework to bypass logits bias in online continual learning. They utilized a multi-similarity loss to weight feature pairs better during training time. At test time, they leveraged reserved samples to generate a generative classifier instead of a softmax classifier. Furthermore, they introduce an auxiliary loss to improve the ability of multi-similarity loss to learn from new data.