Improving Task-free Continual Learning by
Distributionally Robust Memory Evolution
Abstract
Task-free continual learning (CL) aims to learn a non-stationary data stream without explicit task definitions and not forget previous knowledge. The widely adopted memory replay approach could gradually become less effective for long data streams, as the model may memorize the stored examples and overfit the memory buffer. Second, existing methods overlook the high uncertainty in the memory data distribution since there is a big gap between the memory data distribution and the distribution of all the previous data examples. To address these problems, for the first time, we propose a principled memory evolution framework to dynamically evolve the memory data distribution by making the memory buffer gradually harder to be memorized with distributionally robust optimization (DRO). We then derive a family of methods to evolve the memory buffer data in the continuous probability measure space with Wasserstein gradient flow (WGF). The proposed DRO is w.r.t the worst-case evolved memory data distribution, thus guarantees the model performance and learns significantly more robust features than existing memory-replay-based methods. Extensive experiments on existing benchmarks demonstrate the effectiveness of the proposed methods for alleviating forgetting. As a by-product of the proposed framework, our method is more robust to adversarial examples than existing task-free CL methods. Code is available on GitHub https://github.com/joey-wang123/DRO-Task-free
1 Introduction
Continual learning (CL) is to learn on a sequence of tasks without forgetting previous ones. Most CL methods assume knowing task identities and boundaries during training. Instead, this work focuses on a more general and challenging setup, i.e., task-free continual learning (Aljundi et al., 2019b). This learning scenario does not assume explicit task definition, and data distribution gradually evolves without clear task boundaries, making it applicable to a broader range of real-world problems.
The current widely adopted memory replay approach stores a small portion of previous tasks in memory and replays them with the new mini-batch data. The CL model would overfit the memory buffer, and this approach could be gradually less effective for mitigating forgetting as the model repeatedly learns the memory buffer (Jin et al., 2021), illustrated in Figure 1 (a). The model could memorize the memory buffer, and previous knowledge will be quickly lost. Furthermore, there is a big gap between memory data distribution and the distribution of all the previous data examples. These methods ignore the high uncertainty of the memory data distribution since a limited memory buffer cannot accurately reflect the stationary distribution of all examples seen so far in the data stream, illustrated in Figure 2 (a). Most existing CL works ignore this issue.
To address the above issues, we propose a distributionally robust optimization framework (DRO) to evolve the memory data distribution dynamically. This learning objective makes the memory data increasingly harder to be memorized and helps the model alleviate memory overfitting and improve generalization, illustrated in Figure 1 (b) and (c). In addition, the proposed DRO framework considers the underlying high uncertainty of memory data distribution. It evolves memory data distribution to fill the gap between the memory data distribution and the ideal stationary distribution of all the previous data, illustrated in Figure 2 (b). We optimize the model performance under the worst-case evolved memory data distribution since we cannot know the exact distribution of all the previous examples. The model can thus learn substantially more robust features with performance guarantees than previous work. For the image domain, adversarial examples can have the same appearance as natural images but have different classification results. Our proposed DRO memory evolution framework is robust to such adversarial examples due to the worst-case performance optimization on the evolved memory data distribution.

(easy to memorize and overfit)

(diverse and hard)

(diverse and harder to classify)

(raw memory data)

(evolved memory data)
Formally, we first design energy functional that measures the degree of forgetting on a specific memory data distribution and the distributional distance between the evolved and raw memory distribution. The goal is to minimize the energy functional for the worse-case performance probability measure (density) that is within the neighbor probability measures of the raw memory data probability measure . We name this optimization as task-free DRO. However, it is extremely challenging to solve this optimization problem in an infinite-dimensional probability measure space (function space) which contains an infinite number of probability measures. To efficiently solve the task-free DRO, we formulate it from a new continuous dynamics perspective and convert it into a gradient flow system. Specifically, the memory data distribution evolves in probability measure space as Wasserstein gradient flow (WGF), and model parameters evolve in Euclidean space. We name it as Dynamic DRO, which makes it convenient to use function gradient-descent in probability measure space to solve the task-free DRO. Also, it facilitates the derivation of different methods for memory data distribution evolution. We then introduce three specific memory evolution methods to solve the Dynamic DRO, including Langevin Dynamics (Welling & Teh, 2011), Stein Variational Gradient Descent (Liu & Wang, 2016), and Hamiltonian flow (Ma et al., 2015; Liu et al., 2019). The proposed memory evolution framework is general, flexible, and easily extendable, with many potential extensions for future research. We evaluate the effectiveness of the proposed framework by performing comprehensive experiments on several datasets and comparing them to various strong baselines. We summarize our contributions as follows:
-
•
We propose the first principled, general, and flexible memory evolution framework for task-free CL from the perspective of distributionally robust optimization, named task-free DRO. Our proposed method is substantially more effective for mitigating forgetting. As a by-product of the proposed DRO framework, our method is more robust to adversarial examples than previous works.
-
•
We formulate the task-free DRO from a new continuous dynamics perspective and cast it as a gradient flow system, named Dynamic DRO. We propose a family of memory evolution methods with different ways to efficiently solve the Dynamic DRO, opening up a new research direction for presenting new strategies to evolve the memory data.
-
•
Extensive experiments on several datasets demonstrate the effectiveness of the proposed method for reducing forgetting and increasing the robustness to adversarial examples. Our framework is versatile and can be seamlessly integrated with existing memory-replay-based methods to improve their performance.
2 Related Work
Continual learning (CL)
aims to maintain previous knowledge when learning on sequential tasks with data distribution shift. Most existing CL methods (Lopez-Paz & Ranzato, 2017; Nguyen et al., 2018; Kirkpatrick et al., 2017; Zenke et al., 2017; von Oswald et al., 2019; Wang et al., 2021; Saha et al., 2021; Pham et al., 2021; Wang et al., 2022) are only applicable to the task-aware setting, where there are clear task definitions and boundaries among the sequentially learned task sequences. Task-free continual learning (He et al., 2019; Zeno et al., 2019; Aljundi et al., 2019b; Chrysakis & Moens, 2020) instead focuses on the more general case where the data distribution could change arbitrarily without explicit task splits. This learning scenario has become increasingly important due to the broader application scenarios, and more challenging problem nature (Aljundi et al., 2019b; Lee et al., 2020).
Task-free CL
Existing approaches for task-free CL can be categorized into two classes. The first (majority) one is memory-based methods (Aljundi et al., 2019c, a), which store a small number of data from the previous data stream and replay them with the new mini-batch data later. The second type is the expansion-based method, such as CN-DPM (Lee et al., 2020). However, CN-DPM needs to increase the memory and computation overhead with the network structure’s expansion and the increase of the network parameters. Hence, this work focuses on memory-replay-based methods without expanding the network structure since it is simple and effective. Most existing works in this category (Chaudhry et al., 2019b, a) directly perform replay on the raw data without any adaptation. MIR (Aljundi et al., 2019a) proposes to replay the samples with which are most interfered. GEN-MIR (Aljundi et al., 2019a) further uses generative models to synthesize the memory examples. The heuristic method, GMED (Jin et al., 2021), proposes to edit memory examples so that the examples are more likely forgotten and harder to be memorized. Our methods share similar motivations with GMED, which individually edits the memory data without considering memory data distribution uncertainty and population-level statistics. In contrast, our DRO framework focuses on population-level and distribution-level evolution. Orthogonal to our work, Gradient-based Sample Selection (GSS) (Aljundi et al., 2019c) focuses on storing diverse examples. These methods lack theoretical guarantees. In contrast, our framework is principled and focuses on evolving memory data distributions.
Distributionally robust optimization (DRO)
is an effective optimization framework to handle decision-making under uncertainty (Rahimian & Mehrotra, 2019). The basic idea of DRO is first to construct a set of probability distributions as an ambiguity set and minimize the worst-case performance in this ambiguity set, thus guaranteeing the model performance. There are various applications of DRO in machine learning problems, including tackling the group-shift (Sagawa et al., 2020), subpopulation shift (Zhai et al., 2021), and class imbalances (Xu et al., 2020).
To our best knowledge, our work is the first principled method with DRO for memory evolution in task-free CL, named task-free DRO. It dynamically evolves memory data distributions to avoid forgetting and learn robust features. In addition, we formulate the proposed task-free DRO from a new continuous dynamics perspective, making it convenient to handle the evolving memory data distribution with different evolution dynamics. Besides, we propose three ways to evolve the memory data, opening up a new research direction to explore more effective memory evolution methods.
3 Method
In this section, we first present the problem setup in Section 3.1 for the task-free CL setting. Then, we propose our task-free DRO framework in Section 3.2. Next, we view the task-free DRO from a new continuous dynamics perspective and formulate the task-DRO in an equivalent gradient flow system, named Dynamic DRO, in Section 3.3. In Section 3.4, we present three specific memory evolution methods to solve the Dynamic DRO efficiently.
3.1 Problem Setup
A sequence of mini-batch labeled data sequentially arrives at each timestamp and forms a non-stationary data stream. Each data point is associated with a latent task identity , where denotes the mini-batch data received at timestamp , is the data label associated with . According to (Aljundi et al., 2019b), a more general definition of task-free CL is that data distribution shift could happen at any time without explicit task splits. Our method can be directly applied to those more general cases as well. During both the training and testing time, the task identity is not available to the learner. At the same time, a small memory buffer is maintained, and replay the data in when learning the new task to avoid forgetting the previously learned knowledge. The memory buffer is updated by reservoir sampling (RS), similar to (Riemer et al., 2019). The goal is to learn a model to perform well on all the tasks seen until timestamp . Standard memory replay for CL (Chaudhry et al., 2019b) is to optimize an objective under a known probability distribution . Formally speaking, CL with standard memory replay can be expressed as:
(1) |
where are model parameters and is the raw memory buffer data with probability measure (density) , i.e., . is the loss function associated with the data . In the following, we temporally omit the term due to the fact that is the mini-batch data arrived at timestamp and does not depend on the memory data distribution.
3.2 DRO for Task-free CL
Distributionally Robust Optimization (DRO) (Rahimian & Mehrotra, 2019) is a systematic and elegant framework to model the decision-making with ambiguity in the underlying probability distribution. For task-free CL, different from the standard memory-replay methods in Section 3.1, implicitly assuming is known. In contrast, our proposed DRO framework takes that the underlying actual probability distribution of memory data is unknown and lies in an ambiguity set of probability distributions. Modeling the memory data uncertainty is particularly useful when the memory buffer is small compared to the whole dataset since the memory has limited coverage to approximate the stationary distribution of all examples seen so far, illustrated in Figure 2 (a). Thus, there is significant uncertainty in modeling the multi-task learning scenarios (the performance upper bound) with only a small memory buffer. The proposed DRO framework optimizes the worst-case performance in the ambiguity set of probability distributions since we cannot access the distribution of all the previous data. Therefore, it helps the model generalize to previous tasks since it can potentially narrow the gap between the memory data distribution and the distribution of all the previous data, illustrated in Figure 2 (b). As a by-product of this optimization framework, it also helps learn features robust to data distribution perturbations. On the other hand, the memory buffer is updated slowly during CL (e.g., by reservoir sampling), and standard memory-replay repeatedly trains the memory buffer, and the CL model can easily overfit the memory buffer, as illustrated in Figure 1 (a). Thus, the memory buffer could become less effective for mitigating forgetting. By optimizing the worst-case evolved memory data distribution at each iteration, our proposed DRO can also alleviate the memory overfitting problem by transforming the memory data to make them more difficult to memorize. This is illustrated in Figure 1 (b) and (c). Mathematically speaking, the proposed DRO for task-free CL can be expressed as:
(2) | |||
(3) | |||
(4) |
where the inner optimization is to gradually make the memory data distribution increasingly harder to be memorized. in Eq. (3) denotes the ambiguity set of probability measures (distributions or densities) for the memory data distribution to characterize its uncertainty. One common choice to define is through Kullback-Leibler (KL) divergence. denotes the KL divergence between probability measure and , where is the target worst-case evolved memory data distribution, i.e., the probability distribution that achieves . is a constant threshold to characterize the closeness between and to ensure the worst-case evolved memory data distribution does not deviate from the raw memory data distribution too much. Eq. (4) constrains the gradient dot product between the worst-case evolved memory data distribution and raw memory data distribution, i.e., , to avoid the evolved memory data deviate from the raw memory data too much. Intuitively, if the gradient dot product is positive, it means the evolved memory data has a similar update direction compared to the raw data. is a threshold to determine the constraint magnitude.
To solve the optimization, i.e., Eq. (2-4), the worst-case optimization that involves the optimization within the KL-divergence ball is generally computationally intractable since it involves the optimization over infinitely many probability distributions. To address this problem, by Lagrange duality (Boyd & Vandenberghe, 2004), we convert Eq. (2-4) into the following unconstrained optimization problem (detailed derivations are put in Appendix B):
(5) | |||
Where and control the magnitude of regularization. Since the KL-divergence term is implicitly handled by gradient flow (discussed in the following sections), we set for simplicity throughout this paper. The gradient of the third term (gradient dot product term) can be efficiently approximated by finite difference in practice. The optimization Eq. (5) is still computationally hard to solve because the inner optimization is over probability measure space, which is an infinite-dimensional function space. We name Eq. (5) as task-free DRO.
3.3 Task-free DRO: A Continuous Dynamics View
To make it tractable to solve the task-free DRO Eq. (5), we formulate it from a new continuous dynamics perspective. This new perspective brings significant advantages over directly solving Eq. (5): 1) the optimization of Eq. (5) over probability measure space can be converted into a continuous probability distribution evolution, equivalent as a WGF, enabling gradient-based solutions in probability measure space (function space); 2) we can efficiently solve the WGF by various methods, which provide potential derivations of many different memory evolution methods. We then propose a novel solution by decomposing the task-free DRO Eq. (5) into a gradient flow system. Specifically, we solve the inner optimization problem for memory evolution with WGF in Wasserstein space of probability measures and solve the outer optimization problem for the model parameters with gradient flow in Euclidean space. We convert the task-free DRO into a gradient flow system that alternately updates the memory evolution and model parameters.
Given a memory buffer at timestamp , the raw memory data is , where is the memory buffer size. We perform a similar memory evolution procedure at each CL timestamp and omit the CL timestamp for notation clarity. We denote as the datapoint in the evolved memory buffer after evolution steps. The raw memory data is assumed to be i.i.d. sampled from the random variable , i.e., . follows the probability distribution , i.e., . At evolution time , the memory data is evolved as random variable , i.e., and probability distribution of random variable follows the probability measure , i.e., . The empirical measure on the evolved memory buffer at time is defined as and is the Dirac measure. We model the memory evolution process as continuous WGF in probability measure space, i.e., use to model the probability distribution evolution of memory data. The evolving will in turn determine the memory evolution process in Euclidean space.
Below, we define and present the gradient flow in Wasserstein space. Let denote the space of probability measures on with finite second-order moments. Each element is a probability measure represented by its density function with respect to Lebesgue measure . The Wasserstein distance between two probability measures is defined as:
where . is the joint probability measure with marginal measure of and respectively. Thus, forms a metric space.
Definition 3.1 (Wasserstein Gradient Flow).
(Ambrosio et al., 2008). Suppose we have a Wasserstein space . A curve of of probability measures is a Wasserstein gradient flow for functional if it satisfies
(6) |
where means defined as, and is the divergence operator of a vector-valued function , where and are the th element of and ; is the gradient of a scalar-valued function. is the Wasserstein gradient of functional at , where is the first variation of at . The first variation of a functional in function space is analogous to the first-order gradient of a function in Euclidean distance. We put more detailed definition in Appendix D. Intuitively, the WGF describes that the probability measure follows the steepest curve of the functional in Wasserstein space of probability measures (function space) to gradually move towards the target probability measure.
We define the energy functional for memory evolution as the following:
(7) | |||
(8) |
By defining such energy functional , the Eq. (5) can be equivalently solved by the following gradient flow system Eq. (9, 10), we name it as Dynamic DRO.
; | (9) | ||||
, | (10) |
3.4 Training Algorithm for Dynamic DRO
We propose three different methods for efficiently solving the Dynamic DRO in Eq. (9)-Eq. (10). The first solution is Langevin dynamics with a diffusion process to evolve the memory data distribution; we name this method WGF-LD. Next, different from WGF-LD, which relies on randomness to transform the memory data, we kernelize the WGF in Eq. (9) by solving the WGF in reproducing kernel Hilbert space (RKHS). It deterministically transforms the memory data; we name this method WGF-SVGD. Furthermore, we generalize the above WGF and improve their flexibility to incorporate prior knowledge or geometry information. One instantiation of this general WGF uses Hamiltonian dynamics; we name it WGF-HMC. More novel memory evolution methods are worth exploring in future work.
Before introducing the proposed solutions, we first present some preliminaries for solving the WGF. By calculus of variation (Miersemann, 2012), the first variation for the KL divergence and are (Ambrosio et al., 2008):
Langevin Dynamics for Dynamic DRO.



If we directly use the energy functional (Eq. (7)) in Eq. (9), solving gradient flow Eq. (9) corresponds to the Langevin dynamics with the following stochastic differential equation (Welling & Teh, 2011):
(11) |
where is the memory evolution process as previously defined. is the standard Brownian motion in (Bass, 2011). If evolves according to the Langevin dynamics Eq. (11) in Euclidean space, then evolves according to gradient flow Eq. (9) in the space of probability measures (Jordan et al., 1998). If we discretize the above equation and view each datapoint in memory as one particle, the memory buffer data evolves with Langevin dynamics to obtain diverse memory data by the following updates:
(12) |
As illustrated in Figure 3, the first term in Eq. (12) drives the particles (memory data) towards the worst-case memory data distribution to make the memory data gradually harder to be memorized by dynamically increasing the energy functional. For the second term, it adds noise to encourage diversity in the transformed memory data, where is standard Gaussian noise, and is step size, i.e., a proper amount of added Gaussian noise tailored to the used step size. We name this memory evolution method as WGF-LD.
Kernelized Method for Dynamic DRO.



We replace the Wasserstein gradient by the transformation under the integral operator ; where the RKHS space induced by the kernel is denoted by . The probability measure in the kernelized Wasserstein space actually follows the kernelized WGF (Liu, 2017):
(13) |
Eq. (13) can be viewed as the WGF Eq. (9) in RKHS. It indicates that the random variable which describes the evolved memory data at time evolves as the following differential equation (Liu, 2017):
(14) |
This kernelized version is the deterministic approximation of the WGF in Eq. (9) (Liu & Wang, 2016). If we discretize the above equation and view each datapoint in memory as one particle, we can obtain the following memory evolution update equation:
(15) |
As illustrated in Figure 4, the first term drives the memory data towards the worst-case memory data distribution by increasing the energy functional. The update is driven by the kernel weighted sum of the gradients from the memory data points, thus smoothing the memory data gradients. The second term serves as a repulsive force that prevents the memory data points from collapsing into a single mode, thus diversifying the memory data population. In this paper, we use Gaussian kernel . We name this memory evolution method as WGF-SVGD. We put detailed derivations of this evolution equation in Appendix E.
General Memory Evolution for Dynamic DRO.
(Ma et al., 2015) found that any continuous Markov process that provides samples from the target distribution can be written in a very general sampler form. The corresponding general WGF for memory evolution can be written as:
(16) |
Where is a positive semidefinite diffusion matrix, is a skew-symmetric curl matrix representing the deterministic traversing effect (Ma et al., 2015). One particular case is:
Where is the friction term, and is the identity matrix. This WGF corresponds to Hamiltonian dynamics (Chen et al., 2014) and can be solved by the following evolution:
(17) |
Where is the momentum variable, and is the momentum weight. We name this method as WGF-HMC.
The most attractive property of this WGF for memory distribution evolution is that we can freely specify the matrix and tailored to practical requirements. We can consider prior knowledge or geometry information by designing tailored and , or develop the kernelized version of this general WGF. These research directions specialized for CL are left as future work to explore. Our framework is quite flexible and general due to the energy functional design and WGF specification.
The proposed memory evolution algorithm is shown in Algorithm 1, with the flexibility to use various evolution methods. Line 3-4 describes that a mini-batch data arrives at time and samples a mini-batch data from the memory buffer. Line 5-7 is to evolve the mini-batch memory data with steps depending on using which evolution methods. Line 8 updates the model parameters with the evolved memory data and mini-batch data received at time . Line 9 updates the memory buffer with the mini-batch data received at time using reservoir sampling. Note that we do not replace the raw memory data with the evolved memory data for implementation simplicity in the current version. If we replace the raw memory data with the evolved one, we can reduce the number of evolution steps needed at each CL timestamp to improve efficiency since an example can be adequately evolved after accumulating many timestamps. Earlier examples can be evolved less frequently than the later ones. But replacing the raw memory data with the evolved one could slightly reduce the performance in our experiment. Our method needs to store a mini-batch of evolved memory data. This memory cost is negligible compared to the entire data stream memory buffer. We can view memory evolution from two perspectives. First, local evolution evolves the current raw memory data distribution with several adaptation steps. Second, global evolution evolves the memory data at different CL timestamps due to different model parameters.
Discrete input. For the application of our methods in the discrete input domain (such as text), text can be embedded in continuous space (e.g., word embedding) and then evolve on embedding with our methods.
4 Experiments
To evaluate the effectiveness of our memory evolution methods, we compared a variety of state-of-the-art baseline approaches. We first describe the benchmark datasets and baselines in Section 4.1. Then, we compare various baselines on several datasets in Section 4.2, and evaluate the methods in terms of robustness to adversarial examples in Section 4.3. We perform ablation study in Section 4.4.
4.1 Experiment Setup
CIFAR10, following (Aljundi et al., 2019a), we split the CIFAR-10 dataset into 5 disjoint tasks with the same training, validation, and test sets.
MiniImagenet, following (Aljundi et al., 2019a), we split MiniImagenet (Vinyals et al., 2016) dataset with 100 image classes into 20 disjoint tasks. Each task has 5 classes.
CIFAR-100 (Krizhevsky, 2009), contains 100 image classes. We also split it into 20 disjoint tasks.
Baselines. We performed comprehensive experiments by comparing to the following strong baselines, including Experience Replay (ER) (Chaudhry et al., 2019b), Maximally Interfering Retrieval (MIR) (Aljundi et al., 2019a), AGEM (Chaudhry et al., 2019a), Gradient-Based Sample Selection (GSS-Greedy) (Aljundi et al., 2019c) and GMED (Jin et al., 2021). Furthermore, following (Jin et al., 2021), we also compare data augmentation, such as random rotations, scaling, and horizontal flipping applied to memory buffer data in ER and name this baseline as ERaug. Following (Aljundi et al., 2019a), we also compare (1) fine-tuning, which trains on each latent task sequentially when new batches of each task arrive without any forgetting mitigation mechanism; (2) iid online: which trains the model with a single-pass through the iid sampled data on the same set of samples; (3) iid offline: (upper-bound) which trains the model with multiple passes through the iid sampled data. We train the model with 5 epochs for this baseline. Detailed descriptions of the compared baselines are placed in Appendix A.
In addition, our proposed methods are orthogonal to existing memory-replay-based CL methods. Thus, they are versatile, and we can seamlessly combine the proposed methods with them. For illustration, we combine our proposed methods with ER, MIR, and GMED to show the effectiveness. We name the combination methods ER+WGF-LD, ER+WGF-SVGD, ER+WGF-HMC, MIR+WGF-LD, GMED+WGF-LD, etc. Combining with other memory-replay-based methods is straightforward.
Implementation Details. We use the Resnet-18 as (Aljundi et al., 2019a). The number of evolution steps is set to be , the evolution rate is set to be for CIFAR10, for CIFAR100 and for MiniImagenet, and momentum . We set the memory buffer size to be 500 for CIFAR-10 dataset, for CIFAR-100 and for MiniImagenet. All other hyperparameters are the same as (Aljundi et al., 2019a). All reported results in our experiments are the average accuracy of 10 runs with standard deviation.
4.2 Comparison to Continual Learning
We compare the proposed methods to various task-free CL baselines. Table 1 shows the effectiveness of combining the proposed method with existing memory-replay methods, e.g., ER, MIR and GMED. We can observe that our method outperforms these strong baselines. In particular, for ER and ER + WGF methods, our method outperforms baselines by , , and on CIFAR10, CIFAR-100, and MiniImageNet, respectively. For MIR and MIR + WGF methods, our method outperforms baselines by , , and on CIFAR10, CIFAR-100, and MiniImageNet, respectively. For GMED and GMED + WGF methods, our method outperforms baselines by , , and on CIFAR10, CIFAR-100, and MiniImageNet, respectively. Our methods outperform baselines because they dynamically evolve the memory data distribution and sufficiently explore the input space in a principled way. The proposed methods generate more diverse memory data, and the evolved memory becomes more difficult for the CL model to memorize than baseline methods. In addition, WGF-SVGD generally performs better than WGF-SGLD and WGF-HMC. We believe this is because, in RKHS, the evolved memory data is encouraged to be far apart by the kernel repulsive forces; the evolved memory data may better represent the distribution of all the previous data.
Algorithm CIFAR10 CIFAR-100 MiniImagenet fine-tuning A-GEM GSS-Greedy ER ER + WGF-LD 21.5 1.3 ER + WGF-SVGD 27.6 1.3 ER + WGF-HMC 37.8 1.3 MIR MIR + WGF-LD 38.2 1.2 21.6 1.2 MIR + WGF-SVGD 27.4 1.2 MIR + WGF-HMC GMED (ER) GMED + WGF-LD 38.4 1.6 GMED + WGF-SVGD 21.8 1.5 28.7 1.5 GMED + WGF-HMC ERaug + ER ERaug + WGF-LD ERaug + WGF-SVGD 47.9 2.5 32.2 1.5 ERaug + WGF-HMC 20.3 2.1 iid online iid offline
Algorithm CIFAR-10 CIFAR-100 Mini-Imagenet ER GMED ER + WGF-LD 3.0 0.2 3.1 0.1 ER + WGF-SVGD ER + WGF-HMC 8.2 0.3
4.3 Robustness to Adversarial Perturbations
In this section, we evaluate the robustness of the CL model to adversarial perturbed examples. Given a classifier , for an image , the goal is to find another example that is close enough to measured by some distance function such that the classifier classifies it into another different class, i.e. . In this paper, we focus on the most commonly used and norm as the distance function.
Our memory evolution methods optimize on the worst-case evolved memory data distribution during CL; the model would be thus naturally robust to adversarial perturbations. For norm attack, we evaluate the robustness under the strong PGD attack (Madry et al., 2018), which constructs adversarial examples with projected gradient descent and norm constraints. The adversarial perturbation magnitude ranges from with 20 steps attack and stepsize of on CIFAR-100 and Mini-ImageNet. For norm attack, we adopt the strong Carlini Wagner attack (Carlini & Wagner, 2017). For illustration, we evaluate the model robustness to adversarial examples after training with ER, GMED, ER + WGF-LD, ER + WGF-SVGD, and ER + WGF-HMC, respectively. Figure 5 shows the PGD attack results on CIFAR-100 and Mini-ImageNet. Our WGF-HMC and WGF-LD memory evolution significantly outperforms naive ER baseline by depending on the perturbation magnitude. In addition, WGF-HMC and WGF-LD perform more robust than WGF-SVGD. We believe this is because the randomness introduced in WGF-HMC and WGF-LD can better explore the input space and thus can generate harder evolved memory data. WGF-SVGD smooths the function gradient by the kernel function, thus may generate less hard examples. Table 2 shows the Carlini Wagner attack results. We can see that under the strong Carlini Wagner attack, ER baseline accuracy becomes zero, and our methods still outperform baselines ranging from on CIFAR-10, CIFAR-100, Mini-ImageNet, respectively. Both results demonstrate the robustness of our proposed methods to adversarial examples.

4.4 Ablation Study
Effects of different memory size. To investigate the effect of different smaller memory sizes on the model performance, we evaluate the effects on Mini-ImageNet with memory sizes of 3000, 5000, and 10000. We evaluate the effects on CIFAR-100 with the memory sizes of 2000, 3000, and 5000. We show the results in Table 3. In most cases, our WGF memory evolution substantially outperforms the baselines with different memory buffer sizes.
CIFAR-100 Memory Size 2000 3000 5000 ER ER + WGF-LD 12.9 1.2 21.5 1.3 ER + WGF-SVGD ER + WGF-HMC 17.2 1.0 MIR MIR + WGF-LD 21.6 1.2 MIR + WGF-SVGD MIR + WGF-HMC 13.2 1.2 17.5 1.1 Mini-Imagenet Memory Size 3000 5000 10000 ER ER + WGF-LD 16.2 1.2 ER + WGF-SVGD 21.3 1.0 27.6 1.3 ER + WGF-HMC MIR MIR + WGF-LD MIR + WGF-SVGD 20.7 1.6 27.4 1.2 MIR + WGF-HMC 15.8 1.7
Effect of number of evolution steps. To investigate the effect of different evolution steps, we compare 3, 5, and 7 evolution steps, respectively. Table 4 shows the performance variation of different number of evolution steps. We can find that the performance improves slightly with an increasing number of evolution steps. For efficiency and sufficiently exploring the input space to evolve harder memory examples, we choose the evolution step of 5.
Evolution Steps 3 5 7 ER + WGF-LD ER + WGF-SVGD 27.6 1.3 ER + WGF-HMC
Hyperparameter sensitivity. Due to space limitation, we put hyperparameter sensitivity analysis, including the regularizer weight and evolution rate , in Appendix C.
Computation cost. We compare the proposed ER + WGF to ER to evaluate its running efficiency. Table 5 shows the efficiency comparison results. We set the simple baseline ER with a running time unit of 1. Our method has 3-4 times the computational cost compared to a simple ER baseline. In future work, we will improve its computational efficiency.
Algorithm running time ER 1.0 ER + WGF-LD 3.4 ER + WGF-SVGD 4.1 ER + WGF-HMC 3.5
5 Conclusion
This paper proposes a novel concept of DRO memory evolution for task-free continual learning to dynamically evolve the memory data distribution to mitigate the memory overfitting issue and fill the gap between the memory data distribution and the distribution of all the previous data. We propose a family of memory evolution methods with WGF. The proposed principled framework is general, flexible, and easily expandable. Future work includes designing more informative functional and novel gradient flow dynamics to incorporate physical intuitions and geometry constraints. Extensive experiments compared to various state-of-the-art methods demonstrate the effectiveness of the proposed method. Interestingly, our methods are more robust to adversarial examples than compared baselines.
6 Acknowledgement
We thank all the anonymous reviewers for their insightful and thoughtful comments. This research was supported in part by NSF through grant IIS-1910492.
References
- Aljundi et al. (2019a) Aljundi, R., Belilovsky, E., Tuytelaars, T., Charlin, L., Caccia, M., Lin, M., and Page-Caccia, L. Online continual learning with maximal interfered retrieval. Advances in Neural Information Processing Systems 32, pp. 11849–11860, 2019a.
- Aljundi et al. (2019b) Aljundi, R., Kelchtermans, K., and Tuytelaars, T. Task-free continual learning. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019b.
- Aljundi et al. (2019c) Aljundi, R., Lin, M., Goujaud, B., and Bengio, Y. Gradient based sample selection for online continual learning. In Advances in Neural Information Processing Systems 30, 2019c.
- Ambrosio et al. (2008) Ambrosio, L., Gigli, N., and Savare, G. Gradient flows: In metric spaces and in the space of probability measures. (Lectures in Mathematics. ETH), 2008.
- Bass (2011) Bass, R. F. Stochastic Processes. Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge University Press, 2011. doi: 10.1017/CBO9780511997044.
- Boyd & Vandenberghe (2004) Boyd, S. and Vandenberghe, L. Convex optimization. Cambridge university press, 2004.
- Carlini & Wagner (2017) Carlini, N. and Wagner, D. Towards evaluating the robustness of neural networks. 2017 IEEE Symposium on Security and Privacy (SP), 2017.
- Chaudhry et al. (2019a) Chaudhry, A., Ranzato, M., Rohrbach, M., and Elhoseiny, M. Efficient lifelong learning with a-gem. Proceedings of the International Conference on Learning Representations, 2019a.
- Chaudhry et al. (2019b) Chaudhry, A., Rohrbach, M., Elhoseiny, M., Ajanthan, T., Dokania, P. K., Torr, P. H. S., and Ranzato, M. Continual learning with tiny episodic memories. https://arxiv.org/abs/1902.10486, 2019b.
- Chen et al. (2014) Chen, T., Fox, E., and Guestrin, C. Stochastic gradient hamiltonian monte carlo. In Proceedings of the 31st International Conference on Machine Learning, 2014.
- Chewi et al. (2020) Chewi, S., Le Gouic, T., Lu, C., Maunu, T., and Rigollet, P. Svgd as a kernelized wasserstein gradient flow of the chi-squared divergence. In Advances in Neural Information Processing Systems, 2020.
- Chrysakis & Moens (2020) Chrysakis, A. and Moens, M.-F. Online continual learning from imbalanced data. Proceedings of the 37th International Conference on Machine Learning, 119:1952–1961, 2020.
- He et al. (2019) He, X., Sygnowski, J., Galashov, A., Rusu, A. A., Teh, Y. W., and Pascanu, R. Task agnostic continual learning via meta learning. https://arxiv.org/abs/1906.05201, 2019.
- Jin et al. (2021) Jin, X., Sadhu, A., Du, J., and Ren, X. Gradient-based editing of memory examples for online task-free continual learning. Advances in Neural Information Processing Systems, 2021.
- Jordan et al. (1998) Jordan, R., Kinderlehrer, D., , and Otto., F. The variational formulation of the fokker–planck equation. SIAM Journal on Mathematical Analysis, 1998.
- Kirkpatrick et al. (2017) Kirkpatrick, J., Pascanu, R., Rabinowitz, N., Veness, J., Desjardins, G., Rusu, A. A., Milan, K., Quan, J., Ramalho, T., Grabska-Barwinska, A., Hassabis, D., Clopath, C., Kumaran, D., and Hadsell, R. Overcoming catastrophic forgetting in neural networks. Proceedings of the national academy of sciences, 2017.
- Krizhevsky (2009) Krizhevsky, A. Learning multiple layers of features from tiny images. Technical report, 2009.
- Lee et al. (2020) Lee, S., Ha, J., Zhang, D., and Kim, G. A neural dirichlet process mixture model for task-free continual learning. In Proceedings of the 17th International Conference on Machine Learning, 2020.
- Liu et al. (2019) Liu, C., Zhuo, J., and Zhu, J. Understanding mcmc dynamics as flows on the wasserstein spac. Proceedings of the International Conference on Machine Learning, 2019.
- Liu (2017) Liu, Q. Stein variational gradient descent as gradient flow. Advances in Neural Information Processing Systems, 2017.
- Liu & Wang (2016) Liu, Q. and Wang, D. Stein variational gradient descent: A general purpose bayesian inference algorithm. Advances in Neural Information Processing Systems, 2016.
- Lopez-Paz & Ranzato (2017) Lopez-Paz, D. and Ranzato, M. Gradient episodic memory for continual learning. Advances in Neural Information Processing Systems, 2017.
- Ma et al. (2015) Ma, Y.-A., Chen, T., and Fox, E. B. A complete recipe for stochastic gradient mcmc. Advances in Neural Information Processing Systems, 2015.
- Madry et al. (2018) Madry, A., Makelov, A., Schmidt, L., Tsipras, D., and Vladu, A. Towards deep learning models resistant to adversarial attacks. Proceedings of the International Conference on Learning Representations, 2018.
- Miersemann (2012) Miersemann, E. Calculus of Variations, Lecture Notes. Leipzig University, 2012.
- Nguyen et al. (2018) Nguyen, C. V., Li, Y., Bui, T. D., and Turner, R. E. Variational continual learning. Proceedings of the International Conference on Learning Representations, 2018.
- Pham et al. (2021) Pham, Q., Liu, C., Sahoo, D., and HOI, S. Contextual transformation networks for online continual learning. Proceedings of the International Conference on Learning Representations, 2021.
- Rahimian & Mehrotra (2019) Rahimian, H. and Mehrotra, S. Distributionally robust optimization: A review. 2019.
- Riemer et al. (2019) Riemer, M., Cases, I., Ajemian, R., Liu, M., Rish, I., Tu, Y., and Tesauro, G. Learning to learn without forgetting by maximizing transfer and minimizing interference. International Conference on Learning Representations, 2019.
- Sagawa et al. (2020) Sagawa, S., Koh, P. W., Hashimoto, T. B., and Liang, P. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. International Conference on Learning Representations, 2020.
- Saha et al. (2021) Saha, G., Garg, I., and Roy, K. Gradient projection memory for continual learning. Proceedings of the International Conference on Learning Representations, 2021.
- Vinyals et al. (2016) Vinyals, O., Blundell, C., Lillicrap, T., kavukcuoglu, k., and Wierstra, D. Matching networks for one shot learning. 29, 2016.
- von Oswald et al. (2019) von Oswald, J., Henning, C., Sacramento, J., and Grewe, B. F. Continual learning with hypernetworks. https://arxiv.org/abs/1906.00695, 2019.
- Wang et al. (2021) Wang, Z., Duan, T., Fang, L., Suo, Q., and Gao, M. Meta learning on a sequence of imbalanced domains with difficulty awareness. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 8947–8957, 2021.
- Wang et al. (2022) Wang, Z., Shen, L., Duan, T., Zhan, D., Fang, L., and Gao, M. Learning to learn and remember super long multi-domain task sequence. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7982–7992, 2022.
- Welling & Teh (2011) Welling, M. and Teh, Y. W. Bayesian learning via stochastic gradient langevin dynamics. Proceedings of the International Conference on Machine Learning, 2011.
- Xu et al. (2020) Xu, Z., Dan, C., Khim, J., and Ravikumar, P. Class-weighted classification: Trade-offs and robust approaches. Proceedings of the International Conference on Machine Learning, 2020.
- Zenke et al. (2017) Zenke, F., Poole, B., and Ganguli, S. Continual learning through synaptic intelligence. https://arxiv.org/abs/1703.04200, 2017.
- Zeno et al. (2019) Zeno, C., Golan, I., Hoffer, E., and Soudry, D. Task agnostic continual learning using online variational bayes. https://arxiv.org/abs/1803.10123, 2019.
- Zhai et al. (2021) Zhai, R., Dan, C., Kolter, J. Z., and Ravikumar, P. Doro: Distributional and outlier robust optimization. Proceedings of the International Conference on Machine Learning, 2021.
Appendix A Baselines
The detailed descriptions of baselines are the following:
Experience Replay (ER)
Maximally Interfering Retrieval (MIR)
(Aljundi et al., 2019a), the goal of MIR is to select the examples that are easily forgettable for replay. The idea of MIR is not using randomly selected data from the memory buffer, but instead replaying the samples that would be (maximally) interfered by the new received data. Following (Aljundi et al., 2019a), we evaluate the model forgetting on 25 examples for Mini-ImageNet dataset, and 50 examples for other datasets.
AGEM
(Chaudhry et al., 2019a), AGEM tries to ensure that at every training step the average episodic memory loss over the previous tasks does not increase. They project the gradient update direction such that they are less interfered with current data by projecting the gradient to the closest in L2 norm gradient that keeps the angle within 90 degree.
Gradient-Based Sample Selection (GSS-Greedy)
(Aljundi et al., 2019c) is to encourage diverse examples in the memory buffer. We use GSS-Greedy, which is efficient and performs the best.
GMED
Appendix B Lagrangian Duality Derivation
The basic idea in Lagrangian duality (Boyd & Vandenberghe, 2004) is to consider the constraints by augmenting the objective function with a weighted sum of the constraint functions. We first convert the optimization Eq. (2), Eq. (3) and Eq. (4) into the following optimization.
(18) | |||
(19) | |||
(20) |
Then, by Lagrangian duality (Boyd & Vandenberghe, 2004), we can get the equivalent constrained optimization:
(21) | |||
where and are the Lagrange multiplier associated with the corresponding inequality constraints.
Appendix C More Experiments Results
Hyperparameter Sensitivity Analysis
We use ER+WGF-LD as ablation study, similar results for other memory evolution methods. We perform sensitivity analysis for the regularization weight of gradient dot product between perturbed memory data and raw data. The results are shown in Table 6. In particular, we show the results that , i.e., without gradient dot product regularization. Also, we perform sensitivity analysis on memory evolution rate in Table 7, 8 and 9.
Hyperparameter CIFAR-10 CIFAR-100 Mini-Imagenet
Appendix D Foundations of Calculus of Variations
In calculus of variations, the first variation is defined as following:
Definition D.1 (First Variations).
The first variation of a functional is the functional at
(22) |
where is arbitrary function.
For more detailed background knowledge of calculus of variations, we recommend the reader refer to (Miersemann, 2012).
Appendix E Derivations of the memory evolution methods
Specifically, we derive the WGF-SVGD as an example:
We define the target worst-case evolved memory data distribution as by the energy function defined above.
We replace the Wasserstein gradient by the transformation under the integral operator ;
The probability measure in the kernelized Wasserstein space actually follows the kernelized WGF (Liu, 2017):
(23) |
Eq. (23) can be viewed as the WGF Eq. (9) in RKHS. It indicates that the random variable which describes the evolved memory data at time evolves as the following differential equation (Liu, 2017; Chewi et al., 2020):
(24) |
First, we derive the kernelized Wasserstein gradient of
(25) |
where, we apply integration by parts in the second identity. means the gradient of the kernel w.r.t. the second argument.
It indicates that the random variable which describes the evolved memory data at time evolves as the following differential equation (Liu, 2017):
(26) |
If we discretize the above Eq. 26 and view each datapoint in memory as one particle, we can obtain the following memory evolution update equation:
(27) |