B YPASSING
L OGITS
B IAS
IN
O NLINE
C LASS -
I NCREMENTAL L EARNING WITH A G ENERATIVE
F RAMEWORK
Anonymous authors
Paper under double-blind review
A BSTRACT
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 classiﬁer.
However, the inherent logits bias problem in the softmax classiﬁer is a main cause of catastrophic forgetting while existing solutions are not applicable for online settings.
To bypass this problem, we abandon the softmax classiﬁer and propose a novel generative framework based on the feature space.
In our framework, a generative classiﬁer 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 classiﬁers, and reduces catastrophic forgetting consistently with a remarkable margin.
I NTRODUCTION
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 ofﬂine 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 difﬁculty of online CL.
In contrast, class-incremental learning (CIL) setting (Rebufﬁ 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).
[Figure]
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 classiﬁer, 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 classiﬁer 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 ofﬂine 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 classiﬁer 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 classiﬁer is more effective in low data regime than discriminative classiﬁer 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 classiﬁer is preferable.
In contrast, the commonly used softmax classiﬁer is a discriminative model.
Concretely, we abandon the softmax FC layer and introduce nearest-class-mean (NCM) classiﬁer (Mensink et al., 2013) for inference, which can be interpreted as classifying in a generative way.
The NCM classiﬁer is built on the feature space on the top of previous network layers.
Thanks to
ER strategy, NCM classiﬁer 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 classiﬁer.
Meanwhile, we prove theoretically that MS loss is an alternative to a training objective of the generative classiﬁer.
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 classiﬁer.
By tuning weight of the auxiliary loss, our method can work well in different data streams.
In summary, our contributions are as follows:
We make the ﬁrst attempt to avoid logits bias problem in online CIL setting.
In our generative framework, a generative classiﬁer
is introduced to replace softmax classiﬁer for inference and for training, we introduce MS loss which is proven theoretically to optimize the model in a generative way.
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.
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 signiﬁcantly.
R ELATED W ORK
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 speciﬁc 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 (Rebufﬁ 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 ﬁeld of online CL, most of methods are on the basis of ER.
Chaudhry et al.
(2019b)
ﬁrst 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 beneﬁt 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 classiﬁer.
A contemporary work (Lange &
Tuytelaars, 2020) proposes CoPE, which is somewhat similar to our method.
CoPE replaces softmax classiﬁer with a prototype-based classiﬁer 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 classiﬁer.
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 ﬁxed and potentially unbounded.
A recent work (Yu et al., 2020) proposes SDC, a CIL method based on DML and NCM classiﬁer.
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 classiﬁes with replay memory and thus need not correct the drift.
O NLINE C LASS -I NCREMENTAL L EARNING WITH A G ENERATIVE F RAMEWORK 3. P RELIMINARIES AND M OTIVATIONS 3.1. O NLINE C LASS -I NCREMENTAL L EARNING
CIL setting has been widely used in online CL literature, e.g. (Aljundi et al., 2019a; Mai et al., 2021), and a softmax classiﬁer is commonly used.
A neural network f ( · ; θ ) : X → R d parameterized by θ encodes data samples x ∈ X into a d -dimension feature f
( x ) on which an FC layer g outputs logits for classiﬁcation: o = W f ( x ) + b .
At each iteration, a minibatch of data B n from a data stream S arrives and the whole model ( f, g ) is trained on B n only once.
The training objective is cross-entropy (CE) loss:
[Equation]
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.
3.1. E XPERIENCE R EPLAY FOR O NLINE C ONTINUAL L EARNING
ER makes two modiﬁcations during online training: (1) It maintains a replay memory M with limited size which stores a subset of previously learned samples.
(2) When a minibatch of new data B n is coming, it samples a minibatch B r from M and uses B n ∪ B r to optimize the model with one
SGD-like step.
Then it updates M with B n .
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 B r .
See Chaudhry et al.
(2019b) for more details about it.
3.1. L OGITS B IAS IN S OFTMAX C LASSIFIER
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 virtually.
In preliminary experiments, we also observe this phenomenon in online CIL setting.
We run ER-reservoir baseline on 5-task Split CIFAR
(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 L CE 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 of M .
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 ofﬂine 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.
3. I NFERENCE WITH A G ENERATIVE C LASSIFIER
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 classiﬁer 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 classiﬁer which is prone to catastrophic forgetting (Rebufﬁ et al., 2017).
We use NCM classiﬁer ﬁrstly suggested by Rebufﬁ et al.
(2017) for CL
and show it is a generative model.
We use M c to denote the subset of class c of M .
The class mean µ c is computed by µ M c
= 1 |M c | (cid:80) x ∈M c f ( x ) .
During inference, the prediction for x ∗ is made by:
[Equation]
In fact, the principle of prediction in Eq (2) is to ﬁnd a Gaussian distribution N ( f ( x ∗ ) | µ M c , I ) with the maximal probability for x ∗ .
Therefore, assuming the conditional distribution p ( z | y = c ) =
N ( z | µ M c , I ) and the prior distribution p ( y ) is uniform, NCM classiﬁer virtually deals with p ( y | z ) by modeling p ( z | y ) in a generative way.
The inference way is according to Bayes rule: arg max p ( y | x ∗ )
=
arg max p ( f ( x ∗ ) | y ) p ( y ) .
The assumption about p ( y ) simpliﬁes the analysis and works well in practice.
In contrast, softmax classiﬁer models p ( y | x ∗ ) in a typical discriminative way.
As discussed above, online CIL is in a low data setting where generative classiﬁers are preferable compared to discriminative classiﬁers (Ng & Jordan, 2001).
Moreover, generative classiﬁers are more robust to continual learning (Yogatama et al., 2017) and imbalanced data settings (Ding et al., 2020).
At each iteration, B n ∪ B r is also highly imbalanced.
Considering these results, we hypothesis generative classiﬁers are promising for online CIL problem.
It should be noted our method only models a simple generative classiﬁer 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.
3. T RAINING WITH A P AIR - BASED M ETRIC L EARNING L OSS FROM A G ENERATIVE P ERPECTIVE
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 classiﬁer.
Especially, we choose the MS loss as a training objective.
MS loss is one of the state-of-the-art methods in the ﬁeld 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 (cid:96) 2 -normalized ﬁrst, from now on, we use z i to denote the (cid:96) 2 -normalized feature of x i and a feature pair is represented in the form of inner product S ij :=
z T i z j .
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:
[Equation]
where α , β and λ are hyperparameters and P i and N i represent the index set of positive and negative samples of x i 1 respectively.
MS loss also utilizes the hard mining strategy to ﬁlter out too uninformative feature pairs, i.e. too similar positive pairs and too dissimilar negative pairs:
[Equation]
where (cid:15) is another hyperparameter in MS loss.
At each iteration we use MS loss on the union of new samples and replay samples L MS ( B n ∪ B r ) to train the model.
The sampling of B r and update of
M are the same as ER-reservoir.
To show the connection between L MS and the generative classiﬁer in Eq (2), we conduct some theoretical analyses.
Proposition 1.
Assume dataset D = { ( x i , y i ) } ni =1 is class-balanced and has C classes each of which has n 0 samples.
For a generative model p ( z , y ) , assume p ( y ) actually obeys the uniform distribution and p ( z | y
= c ) =
N ( z | µ D c , I ) where µ D c = 1 n 0 (cid:80) ni
=
z i I
[ y i =
c ] .
For MS loss assume hard mining in Eq (4) is not employed.
Then we have:
[Equation]
where c ≥ stands for upper than, up to an additive constant c and L Gen − Bin is deﬁned in the following:
[Equation]
The proof of Proposition 1 is in Appendix.
Proposition 1 shows L MS is an upper bound of L Gen − Bin and thus is an alternative to minimizing L Gen − Bin .
The ﬁrst term of L Gen − Bin aims to minimize the negative log-likelihood of the class-conditional generative classiﬁer, while the second term maximizes the conditional entropy H ( Z | Y ) of labels Y and features Z .
It should be noticed L Gen − 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, L Gen − Bin actually optimizes the model in a generative way.
The assumptions in Proposition 1 are similar with those in Section 3.2 about NCM classiﬁer.
The difference lies in that NCM classiﬁer uses { µ M c } computed on replay memory M to approximate { µ D c } .
Therefore, Proposition 1 reveals that MS loss optimizes the feature space in a generative way and it models p ( z | y ) for classiﬁcation which is consistent with the NCM classiﬁer.
The real class means { µ D c } depend on all training data and change with the update of f ( θ ) so that are intractable in online settings.
MS loss can be efﬁciently computed as it does not depend on { µ D c } thus the model can be trained efﬁciently.
During inference, we use approximate class means µ M c to classify.
In Figure 1b, on 5-task Split CIFAR10 benchmark, we empirically show compared to softmax classiﬁer, 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 µ M c of replay memory is a good approximation of µ D c .
With discriminative loss like CE loss, the classiﬁer models a discriminative model p ( y | z ) .
Therefore, if training with discriminative loss and inference with NCM classiﬁer 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.
3. A H YBRID G ENERATIVE /D ISCRIMINATIVE L OSS
However, when addressing classiﬁcation tasks, generative classiﬁer 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 classiﬁer’s performance degenerates as the expected number of classes in B n 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 B n is always ﬁxed to a small value (e.g.
10) in online CIL settings, the number of positive pairs in B n 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 p c ∈ R d to it.
PNCA loss is computed as:
[Equation] [Equation]
Movshovitz-Attias et al.
(2017) suggest all proxies have the same norm N P and all features have the norm N F .
The latter satisﬁes as in MS loss the feature is (cid:96) 2 -normalized, i.e. N F = 1 .
We also set
N P = 1 by normalizing all proxies after each SGD-like update.
In this way, L PNCA is equivalent to a CE loss with (cid:96)
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:
[Equation]
where γ is a hyperparameter to control the weight of L PNCA .
In general, generative classiﬁers have a smaller variance but higher bias than discriminative classiﬁers, and using such a hybrid loss can achieve a better bias-variance tradeoff (Bouchard & Triggs, 2004).
Thus we think introducing the discriminative loss L PNCA 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 L Hybrid ( B n ∪ B r ) , while we only use NCM classiﬁer in
Eq (2) for inference.
In all experiments, we set α = 2 , β = 50 , (cid:15) = 0 .
1 following Wang et al.
[Figure] [Figure]
and λ = 0 .
5 which always works well in online CIL settings.
We only need to tune hyperparemeters γ in Eq (8) for different experiment settings
[Figure]
E XPERIMENTS 4. E XPERIMENT S ETUP
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 ortasks.
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 n 0 = n/C .
We denote p c ( t ) as the occurrence probability of class c at time step t and assume p c ( t ) ∼ N ( t | (2 c − 1) n 0 / 2 , n 0 / 2) .
At each time step t , we calculate p ( t ) =
( p 1 ( t ) , . . . , p C ( t )) and normalize p ( t ) as the parameters of a
Categorical distribution from which a class index c t is sampled.
Then we sample one data of class c t 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 = 5 k on
CIFAR10 and n = 40 k on CIFAR100 and miniImageNet, using all classes in each dataset.
For all datasets, the size of minibatch B n 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 brieﬂy 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 ﬁne-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 ofﬂine 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 B r is always 10.
The budget of memory M 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. M AIN R ESULTS ON Split D ATASETS
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% conﬁdence interval.
[Table] [Table]
In Table 1, we can ﬁnd our method outperforms all baselines on all 6 settings.
The improvement of our method is signiﬁcant 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 classiﬁer [Table] 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 classiﬁer in Table 4.
The
ER-reservoir corresponds to the ﬁrst row and our method corresponds to the last row.
Firstly, we ﬁnd for ER-reservoir, replacing softmax classiﬁer with NCM classiﬁer 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 classiﬁer is much better than proxy-based classiﬁer (row 5&6), and MS loss is critical for NCM classiﬁer (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 modiﬁed in some ways they can be adapted to online CIL.
To better reﬂect the contribution of our method, we adapt iCaRL (Rebufﬁ et al., 2017) and BiC (Wu et al., 2019) to online CIL and compare modiﬁed iCaRL and modiﬁed BiC with our method in Table 3.
iCaRL replaces softmax classiﬁer with NCM classiﬁer and BiC uses a linear bias correction layer to reduce logits bias.
and iCaRL is modiﬁed 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 [Figure] [Table] [Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table] [Table]
old model after the last iteration.
We use reservoir sampling for memory update.
NCM classiﬁer is used for inference.
For modiﬁed 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
[Table]
modiﬁed iCaRL performs very badly and the performances of modiﬁed 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 classiﬁer and our NCM classiﬁer are displayed in
Figure 4b.
We can ﬁnd the extra time of NCM to compute the class means is (about 3%) slight, as the size of memory is limited.
4. R ESULTS ON T ASK - FREE Smooth D ATASETS
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 ﬁnal accuracy after learning the whole data stream.
We can ﬁnd these datasets are indeed more complex as ﬁne-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.
C ONCLUSION
In this work, we tackle with online CIL problem from a generative perspective to bypass logits bias problem in commonly used softmax classiﬁer.
We ﬁrst propose to replace softmax classiﬁer with a generative classiﬁer.
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 signiﬁcant and consistent superiority of our method compared to existing state-of-the-art methods.
A P ROOFS A. P ROPOSITION
Proof.
For simplicity, we ignore the coefﬁcient 1 n both in L MS and L Gen − Bin in the proof.
We denote the two parts in the summation of L MS as L + MS and L − MS respectively, i.e.: L + MS = n (cid:88) i =   α log[1 + (cid:88) j ∈P i e − α
( S ij − λ ) ] L − MS = n (cid:88) i =  β log[1 + (cid:88) j ∈N i e β ( S ij − λ ) ] (9)
Without hard mining, for L + MS we have:
L + MS = n (cid:88) i =   α log[1 + (cid:88) j : y j = y i e − α ( S ij − λ ) ]
≥ n (cid:88) i =  α log[ (cid:88) j : y j = y i e − α ( S ij − λ ) ] c ≥ n (cid:88)
[Equation]
Jensen’s inequality
[Equation]
where c = stands for equal to, up to an additive constant.
For L − MS we can write:
[Equation]
According to Eq (10) and Eq (11), we have:
[Equation]
Now we consider L Gen − Bin .
Firstly, it can be written:
[Equation]
For convenience, we denote the features of data samples whose labels are c as { z c i } n 0 i =1 .
For the ﬁrst part in the right hand of Eq (13), we have:
[Equation]
(cid:88) i = − log p ( z i | y
= y i ) c
=  n (cid:88) i =
(cid:107) z
i − µ
[Equation]
(cid:107)(cid:66) p (
[Equation]
| y
[Equation]
c )
[Equation]
N (
[Equation]
µ
[Equation]
[Equation]
) =
C (cid:88) c
= n 0 (cid:88)
i =
(cid:107)
z c i − µ D c
(cid:107)=
[Equation]
(cid:88) c
= n 0 (cid:88) i = (cid:8) (cid:107)
[Equation]
(cid:107) 22 −
[Equation]
(cid:107)
[Equation]
(cid:107) 22 (cid:9)
[Equation]
[Equation]
c =
[Equation]
(cid:8)
[Equation]
(cid:88) i =
[Equation]
(cid:107) µ D c (cid:107)
[Equation]
(cid:107) µ
[Equation]
c (cid:107) 22 (cid:9) (cid:66) (cid:107)
[Equation]
(cid:107) 22 =
[Equation]
[Equation]
(cid:88) c =
[Equation]
n 0 (cid:88) i =
[Equation]
(cid:107) µ
[Equation]
c (cid:107)
[Equation]
[Equation]
(cid:88) c
= n 0 (cid:88) i = n 0 (cid:88)
j = −
[Equation]
= − n (cid:88) i = (cid:88)
j : y j = y
i
[Equation]
ij (14) Keep in mind that the mean of class c µ D c = 1 n [Equation] n 0 i =
z c i .
For the second part in the right hand of
Eq (13), we have:
[Equation]
According to Eq (14) and Eq (15), we have:
[Equation]
According to Eq (12) and Eq (16), we can obtain:
[Equation]
B D ETAILS ABOUT E XPERIMENT S ETUP B. S PLIT D ATASETS
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.
B. S MOOTH D ATASETS
For a data stream with C classes, we assume the length of stream is N and n 0 =
Nc .
We denote p c ( t ) as the occurrence probability of class c at time step t and assume p c ( t ) ∼ N ( t | (2 c − 1) n 0, n 0 c ) .
At each time step t , we calculate p ( t ) =
( p 1 ( t ) , ..., p C ( 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 [Table] samples of each class is slightly imbalanced.
On CIFAR100 and miniImageNet we set the mean number of samples of each class n 0 = 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 reﬂect 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 CIFAR increases dramatically.
Thus some methods can detect the change of loss to inference the task boundaries although they are not informed and conduct additional ofﬂine 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.
[Table]
B. H YPERPARAMETER S ELECTION
In our method, although there are several hyperparameters in L MS and L PNCA , we only need to tune γ which is the weight of L PNCA in L Hybrid .
The value of other hyperparameters in L Hybrid is ﬁxed as stated in the main text.
We select γ from [0 , 0 . 1 , 0 . 25 , 0 . 5 , 0 .
Especially, γ = 0 makes L Hybrid become L MS .
We follow previous works to use SGD optimizer in all experiments.
However, we ﬁnd 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 ﬁnd the optimal η for L Hybrid is often larger than 0 .
However, when a larger η (e.g. 0 .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
[Figure] 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. [Figure]
[Table]
[Figure]
B. E VALUATION M ETRICS
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 a k,j denote the accuracy on the held-out set of the j -th task after training the model on the ﬁrst k tasks.
For a dataset comprised of T tasks, the Average
Accuracy is deﬁned as follows:
[Equation]
(18) and Average Forgetting can be written as:
[Equation]
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 ﬁnishing training the whole training set.
B. C ODE D EPENDENCIES AND H ARDWARE
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.
C M ORE E XPERIMENTAL R ESULTS C. E FFECT OF P ROXY -NCA L OSS W EIGHT γ
In Table 6, we show the effect of Proxy-NCA loss weight γ on split datasets.
We can ﬁnd 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 classiﬁer.
[Figure] [Figure]
C. R ESULTS WITH D IFFERENT M EMORY S IZES
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 memory M is too small (5 samples per class on average), class mean µ M c cannot approximate the real class mean µ D c well and thus proposed NCM classiﬁer degrades.
C. C OMPARISON WITH T RIPLET L OSS
Yu et al.
(2020) proposes SDC method for conventional CIL based on NCM classiﬁer 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 classiﬁer after training the model with the hybrid objective
L Triplet + γ L PNCA , where L Triplet represents triplet loss.
Please see Hoffer & Ailon (2015) and (Yu et al., 2020) for details about L Triplet .
We report the results of the hybrid objective involving triplet loss and compare it with our hybrid loss ( L MS + γ L PNCA ) in Table 11.
We can ﬁnd our proposed loss is superior to L Triplet + γ L PNCA consistently.
In addition to replace softmax classiﬁer with NCM classiﬁer for online CIL problem, our contributions mainly reﬂect in introducing a hybrid of MS loss and PNCA loss in the view of training the generative NCM classiﬁer.
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).
Methods
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
Chaudhry et al.,
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
Aljundi et al.,
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
Aljundi et al.,
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
ASER
[Table]
et al., 2021) ∗
[Table]
[Table]
[Table] [Table]
Ours
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table]
online
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
ofﬂine
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]