Navigating Memory Construction by Global Pseudo-Task Simulation for Continual Learning
Abstract
Continual learning faces a crucial challenge of catastrophic forgetting.
To address this challenge, experience replay (ER) that maintains a tiny subset of samples from previous tasks has been commonly used.
Existing ER works usually focus on refining the learning objective for each task with a static memory construction policy.
In this paper, we formulate the dynamic memory construction in ER as a combinatorial optimization problem, which aims at directly minimizing the global loss across all experienced tasks.
We first apply three tactics to solve the problem in the offline setting as a starting point.
To provide an approximate solution to this problem in the online continual learning setting, we further propose the
Global Pseudo-task Simulation (GPS), which mimics future catastrophic forgetting of the current task by permutation.
Our empirical results and analyses suggest that the GPS consistently improves accuracy across four commonly used vision benchmarks.
We have also shown that our GPS can serve as the unified framework for integrating various memory construction policies in existing ER works.
Introduction
Data in real world is non-stationary and keeps changing.
Adapting new knowledge while maintaining the old skills learned from previous data is an idealism for intelligent systems.
However, deep artificial neural networks suffer from catastrophic forgetting of old behaviors as the learning of new tasks keeps overwriting the past [30, 32, 33, 41, 34].
To combat this issue, numerous novel algorithms have been designed in continual learning in recent years [37, 13, 28, 8, 20, 2, 27].
Amongst them, the experience replay (ER) methods have been attested as one of the few methods that consistently achieve strong results across different continual learning setups [6, 11, 46, 21].
In the ER, a slightly relieved continual learning setting is considered, where a learner stores a subset of old examples from previous tasks in a fixed-sized memory and jointly trains the memory with the upcoming task.
Most existing ER-based works put rigorous efforts in refining the local learning objective to update the model parameters on one task at a time.
In the methods, they stick to a single static memory construction policy, which is prone to failing in the long task sequence.
For example, selecting random data examples from experienced tasks for the memory buffer can effect good generalization at the very beginning, but the forgetting rate would soon climb up when the tasks sequence becomes longer, as some class representations are totally squeezed out from the memory [11].
This major drawback has inspired us to explore the optimal memory construction with a dynamic policy.
In this work, we formulate the memory construction problem in ER as a combinatorial optimization problem.
Unlike previous memory construction methods [1, 3, 15], we explicitly optimize the global objective, i.e ., the minimum loss of the final model on all observed tasks, by finding the best memory configuration strategy.
As a starting point, we approach this problem in an offline setting, where we can go through the task sequence for multiple trials independently.
By utilizing three tactics, we reduce the intractable search space to a significantly smaller one.
Specifically, for each task, we blend random and class-balanced memories according to a parameter, the switching point .
Then, we use the binary search to find switching points in O
( T log |M| ) , where T is the total number of tasks and |M| is the size of the memory buffer.
Based on the offline solution, in the online continual learning setup, 2 we propose our method Global
Pseudo-task Simulation (GPS) as an approximate solution to the problem.
The GPS mimics the catastrophic forgetting pattern for the current task by creating future pseudo-tasks, and finds approximate switching points based on the pseudo-task simulation.
We examine a few simulation methods and find permutation is the favorable way to synthesize pseudo-tasks.
We conduct experiments on four widely used vision benchmarks.
Our results have shown that the
GPS achieves higher accuracy compared to baselines, especially when we have a long task sequence.
In addition, our empirical analysis verifies that the dynamic memory construction by using GPS is close to the offline solution.
Meanwhile, GPS can be easily applied to other ER variants [6, 9] to further improve their performance.
Preliminary and Notations
Continual Learning
In continual learning, the model f ( θ ) experiences a stream of data points ( x i , y i ) ∼ P i from a sequence of tasks
t i , where i ∈ T = { 1 , ..., T } , and P i is an unknown i.i.d.
distribution of task t i .
Without experience replay, the model f ( θ ) is optimized on one task at a time following the task sequence under the tight constraint that the examples from previous tasks cannot be accessed [38].
We denote θ i as the parameter of f ( · ) after training task t i , and we refer to the function g ( · ) that updates θ i for each task t
i as the local updating method .
Once the local updating method is determined, θ T can be derived recursively by θ i
=
g
( θ i − 1 , P i ) from θ 0 , which is the initialization point.
After sequentially training T tasks, the objective of continual learning is to achieve the minimum loss across all observed tasks with the final model in the end.
We write the summed global loss L G as in Eqn.
(1), where θ T is the final parameter after T tasks and l ( · ) is the cross-entropy loss.
For convenience, we also denote the global loss for a single task i as L Gi = E ( x i ,y i ) ∼ P i ℓ ( y i , f ( x i ; θ T )) .
[Equation]
Experience Replay Previous works [13, 38, 46] have proposed a series of local updating methods to optimize the global objective.
Amongst them, one effective way is experience replay (ER) from [11].
Experience replay relieves a bit on the tight constraint in continual learning by adding a fixed-sized memory buffer M to store a limited subset of seen examples.
We denote the memory after training task t i as M i .
The modified local updating method g treats the memory as another input, and jointly optimizes examples of the current task and examples stored in the memory, with a factor λ on the loss of memory examples as shown in Eqn.
Thus, θ i is iteratively updated by θ i = g
( θ i − 1 , P i , M i − 1 ) .
[Equation]
Both empirical results [11, 6] and theoretical analysis [21] have suggested that the local updating method g of experience replay is effective on reducing the global loss L G .
If not specially specified, we refer to local updating method g as Eqn.
(2) in the following text.
Problem Formulation: Dynamic Memory Construction
Most previous works based on ER regard the global loss L G as a function of g with a static memory construction strategy for M .
They utilize various techniques like regularization [6, 9] or memory
[Figure]
Existence
Store
Replay
Separate
Store
Replay
Separate Separate
Store
Replay
Separate
Store
Replay
Search Search
Search Search
Task sampling [1] to further refine the local updating method g .
Unlike them, we view the global loss
L G as a function of the memory M , and explicitly minimize L G by optimizing the memory without modifying the local updating methods in Eqn.
Following the setup of ER, we propose dynamic memory construction, which aims at finding the best memory construction M to optimize the global objective L G , as defined in Eqn.
This combinatorial optimization problem is expressed by the Eqn.
(4), where we minimize the global objective by considering the memory M i after task t
i as variables.
[Equation]
We denote the part in M i storing the examples of task
t j as M i,j .
There are four intrinsic constraints for the optimization problem.
In all constraints, i, j, i ′ ∈ T .
• M i is the union of memories {M i,j } j ∈T .
The collection {M i,j } j ∈T is mutually disjoint.
• No future examples in the memory, i.e ., M i,j = ∅
when i < j . •
The size of memory is the same across the training procedure from t 1 to t T , denoted as |M| .
• As we cannot access previous examples that are not stored in the memory, once the set for task
t j in the memory is constructed after training task t j , its size will not increase.
Thus, the memory set for task j in M i is always a subset of that in M i ′ given j ≤ i ′ < i .
An Offline Solution: Reduce the Search Space
In order to reduce the intractable search space of M T quantitatively, we first consider the dynamic memory construction problem in an offline setup as the starting point for analyzing the realistic online setting.
In the offline setup, we can go through the task sequence for multiple trials independently, but we are still strictly not allowed to access previous examples that are not in M in each trial.
We take three tactics to reduce the search space, referred to as the equal memory heuristic , the base policy assumption and the switching point existence .
Fig.
1 illustrates how we apply three tactics to the
S-CIFAR-10 dataset.
Based on these tactics, we provide an approximate solution to the problem.
4.1 Equal Memory Buffer for Each Task
We first take the equal memory heuristic from [11], which has shown that an equal size of memory buffer for each observed task is effective to avoid catastrophic forgetting.
Based on this tactic, we add |M i,j | = |M| /i , where i ≥ j , to the previous constraints list.
Given a fixed size of each M i,j , instead of optimizing M i from previous observed tasks jointly, we can independently optimize each
M i,j and construct M i from M i,j .
To this end, we replace the optimization objective Eqn.
(4) by a simplified version Eqn.
(5), taking M i,j as variables.
[Equation]
However, given the equal memory heuristic, the search space in Eqn.
(5) is still very large.
For each task t j , suppose the total number of examples for task t j is n j and n j > |M| , M i,j has more than (cid:0) |M| |M| /i (cid:1) different constructions.
4.2 Mix of Base Policies
To further reduce the search space in Eqn.
(5), we introduce two base policies, ER-Res and ER-RingFull [11].
For a given task t i , ER-Res builds a memory by random samples, while ER-Ring-Full builds a memory by selecting the same number of samples from each class.
We take the base policy assumption, where we deem that the memories having the same size and taking the same base policies are the same.
It implies that even though two memory buffers contain different data examples, they are still identified as the same as long as they meet these two rules.
This assumption ignores randomness of data selection within the same policy.
It is backed up by analysis in DER [6], which shows the standard deviation of accuracy on different benchmarking datasets is quite small ( ∼ 0.5) when using the same policy with a relatively large |M| .
Based on the assumption, we separate M i,j into two disjoint parts and take the mixed policy, where M res i,j and
M ring-full i,j represent two parts in M i,j , namely the former taking the ER-Res and the latter taking ERRing-Full policies, respectively.
For completeness, we extend the subset constraint to M res i,j ⊆ M res i ′ ,j ,
M ring-full i,j ⊆ M ring-full
i ′ ,j , where j ≤ i ′ <
i .
Previous studies of ER [11] have shown the randomness (ER-Res) is crucial in a large memory, while guaranteeing the equal representation of each class (ER-Ring-Full) is crucial under a tiny memory.
As the number of tasks grows, the size of memory for each task t i becomes smaller.
Under a mixed policy, it is natural to first shrink the ER-Res part of the memory and then shrink the ER-Ring-Full part of the memory.
By doing so, given M res j,j and M ring-full j,j , we can determine M res i,j and M ring-full i,j accordingly for each i > j .
We denote the size of M ring-full j,j as a j and derive the size of M res j,j as ( |M| /j )
− a j .
Substituting the collection of sets {M i,j } i,j ∈T by an integer variable a j , we therefore further simplify the optimization objective, as in Eqn.
[Equation]
(6) where each a j has |M| /j different choices, significantly smaller than the search space for M i,j in
Eqn.
Notice that the memory construction for the last task t T is not required.
Thus, the total search space equals to |M| T − 1 / ( T − 1)!
, which is still large.
4.3 Existence of a Switching Point
For the memory allocation after each task t j , there exists a gold point a j = s j that assigns exactly the required ring-full memory to keep the best balance of M ring-full i,j and M res i,j for the following task t i .
If the ring-full memory size is not large enough, we lose the power of forcing an equal representation of classes as the task sequence grows.
Conversely, if the ring-full memory is more than enough, we sacrifice the randomness when the task number is still small.
To this end, we assume s j is a unique switching point, i.e ., there exists a switching point s j for each a j , which satisfies the monotonicity
[Equation]
Notice that the global loss of task t j should depend closely on what data we store and replay for task t j , but very loosely on what data we store and replay for other tasks.
Following this intuition, though it is hard to verify a specific point satisfies the condition of Eqn.
(7) for all combinations of { a i } i ∈T / { j } , we can simplify the switching point condition to
[Equation]
Given the switching point existence, though we still have the same search space, instead of a linear search, we can apply a binary search algorithm to reduce the time complexity to O
( T log |M| ) .
During the binary search, if we search by comparing against the exact left and right integer of the point, i.e ., comparing the loss computed by a j + 1 , a j − 1 and a j , the large variance of sampling may cause the algorithm to exit unexpectedly.
To increase the robustness of the algorithm, we take a search stride ϵ , where we compare the loss computed by a j + ϵ, a j − ϵ and a j .
The stride is determined by the benchmark and the size
|M
j | .
The detailed binary search algorithm for s j can be found in our
Appendix A.
This assumption is valid for over 85% of the cases from the observations in Fig.
1 (for the S-CIFARdataset) and Appendix B (for other benchmarks).
For each a j ( i.e ., |M ring-full j,j | ) in the figures, the global loss L G initially decreases monotonically and then increases monotonically as a j grows.
Rarely but possible, due to the variance of sampling, we cannot find the switching point s j .
In such cases, we will choose a j with the minimum loss amongst the values we searched.
Global Pseudo-task Simulation (GPS)
The offline solution of dynamic memory construction requires going through the task sequence for
O ( T log |M| ) times to find { s j } j ∈T , which violates the online continual learning setup.
To circumvent this issue, we propose Global Pseudo-task Simulation (GPS), which provides an approximate solution { ˜ s j } j ∈T to the problem by simulating the future training process under the online setup.
Specifically, we simulate the local updating process Eqn.
(2) by creating pseudo-future tasks .
5.1 Objective Function for Simulation
Perfectly simulating the future is a mission impossible in continual learning [21].
As we have no information about the future tasks, the distribution of the pseudo-future tasks we create could be quite different from the distribution of the real future ones.
To find each approximated switching point ˜ s j more precisely, we intend to use more real tasks and less pseudo-future tasks as possible.
As we are required to allocate examples of task t j to a non-empty set M j,j right after training the task t j , we solve ˜ s j by a simulation process from θ j to θ T , without future modifications.
In theory, we could overwrite the previous switching point s j by a more accurate simulation after task t i , i > j .
However, one risk of overwriting the s j is that we may not have enough examples of task t j in the memory to support the reallocation brought by the new switching point, since more examples of task t j cannot be accessed anymore except the ones stored in M j,j .
Another drawback comes from the drastically increased simulation complexity if we take the overwriting mechanism.
To this end, we modify the offline objective function Eqn.
(6) to the online simulation objective
Eqn.
(9), where ˜ θ j : i is the simulated θ i from the real θ j , for i > j .
[Equation]
[Equation]
Note that ˜ θ j : T is derived recursively from ˜ θ j : i = g
(˜ θ j :( i − 1) , ˜ P
i , ˜ M i − 1 ) , initialized with ˜ θ j : j = θ j .
˜ P
i is the task distribution of the synthesized pseudo-tasks ˜
t i , and ˜ M
i is the simulated pseudo-memory after training the pseudo-task
˜ t
i .
In the online setup, we cannot access the previous tasks as well as the future tasks.
Thus, we will not evaluate the summed global objective L G .
Following the offline
Eqn.
(8), we evaluate on L G j , the global objective of task t j .
5.2 Synthesizing Pseudo-tasks
The goal of our pseudo-task simulation is to find s j precisely, i.e .,
˜ s j ≈ s j .
Concretely, instead of accurately simulating the future training process, we use synthesized pseudo-tasks to mimic the forgetting patterns of task t
j caused by the future tasks .
To achieve this aim, we believe if the real task sequence holds certain properties, it is essential for pseudo-tasks to hold the same set of properties to mimic the same forgetting pattern.
We find most of the existing widely used vision CL benchmarks [6, 25, 43] hold two properties: 1) similar learning difficulty of individual tasks; 2) limited zero-shot transfer ability.
The experimental validation of these properties is in Appendix C. To induce the same level of catastrophic forgetting, we expect a pseudo-task ˜
t j to have similar difficulty as its real counterpart t j in the future, measured by the accuracy in an identical end-to-end training setup [34].
To avoid the similarity between tasks to lead to little forgetting after training on pseudo-tasks, pseudo-tasks should also have low zero-shot accuracy with the model trained on the current task.
If pseudo-tasks can achieve high zero-shot accuracy with the model trained on the current task, the similarity between tasks could result in very little forgetting after training on the pseudo-tasks, hindering our purpose of mimicking the catastrophic forgetting.
[Figure]
Based on these two properties, we synthesize pseudo-future tasks from the task t j by applying different permuting seeds to its input x j to create a series of future tasks { ˜ t j +1 , ..., ˜ t T } .
We achieve this by permuting the pixels of each image on image datasets, i.e., a fresh permutation would be generated and applied to all images within a synthesized task [54].
Besides permutation, we have also considered two other synthesizing techniques that lack a certain property we discussed for comparison.
One is rotation, where we rotate the image inputs of the task t
j gradually by 15 degrees to create pseudo-future tasks [6].
The other is blurring, where we apply the Gaussian blurring into the image using a 5 × 5 filter with growing standard deviation.
Rotation creates pseudo-tasks with similar difficulties as the real tasks, but the zero-shot transfer ability is far too good.
Blurring creates pseudo-tasks with limited zero-shot transfer ability, yet the task difficulty is increasing along the pseudo-task sequence.
5.3 Construct Pseudo-memories
Fig.
2 visualizes the process of pseudo-task training and pseudo-memory construction.
During the simulation process after task t j , we try different a j with a binary search and pick the best one as ˜ s j based on the online objective Eqn.
We start from ˜ M j , which is the same as the real M j .
The construction for ˜ M
i
( i > j ) is different for real tasks and pseudo-tasks.
For real tasks t j ′ , j ′ ∈ { 1 , ..., j } , ˜ M i,j ′ is the real M i,j ′ determined for a given a j ′ , as we discussed in § 4.2.
Note that the approximated switching points { ˜ s j ′ } j ′ ∈{ 1 ,..,j − 1 } for the previous j − 1 tasks are solved before ˜ s j .
For pseudo-tasks ˜ t j ′ , j ′ ∈
{ j + 1 , ..., i } , ˜ M i,j ′ is constructed by randomly selecting |M| /i pseudo-data from ˜ t j ′ .
5.4 Other Implementation Details
For the efficiency of simulation, the number of examples of the synthesized pseudo-tasks we use in the simulation is equal to |M| .
As the simulation quickly converges on a small number of examples, we train fewer epochs for each task compared with the real training process.
Besides, when the number of tasks T are large or unknown, we extend GPS by simulating a fixed-sized sliding window of future tasks for the sequence, e.g ., simulating 10 pseudo-future tasks for each task.
Also, during the local update of each task t i , for a smooth transition, we allow the current training task t i to take
[Table]
up to |M| /i
the size of the memory without changing M i,j for any previous task t j .
We also put the detailed algorithm for GPS in Appendix A.
Experiments 6.1 Experimental Setup
Datasets We carry out evaluations on four widely used vision benchmarks in continual learning,
P-MNIST, S-CIFAR-10, S-CIFAR-100 and TinyImageNet [43, 6, 25].
P-MNIST was proposed in [18].
It contains 10 tasks where the first task is the MNIST dataset [23] while the later ones are constructed by permuting each image in MNIST with an unique permutation seed.
The S-CIFARis constructed by splitting CIFAR-10 [17] into 5 sequential tasks where each task contain 2 classes and 12,000 images [22, 6].
Similarly, we split CIFAR-100 [17] into 10 tasks where each one contains 10 classes and 6,000 images to construct S-CIFAR-100.
The TinyImagenet [48] is a subset of
ImageNet [14] with 200 classes.
We split it into 10 consecutive tasks with 20 classes per task.
Architectures For P-MNIST, we apply a fully connected network with two hidden layers.
Each comprises 100 ReLU units.
For S-CIFAR-10, S-CIFAR-100 and TinyImageNet, we use Resnet following [6] and [13].
Baselines The baselines we used in experiments include ER-Res, ER-Ring-Full and ER-Hybrid [11].
ER-Hybrid is a mix of ER-Res and ER-Ring-Full, where the memory construction strategy would switch from the former to the latter once observing only one sample of some class is left in M .
We also compare to non-ER methods: online EWC (oEWC) [44], iCaRL [37], A-GEM [10] and GSS [3].
Training Details: Our training all use stochastic gradient descent (SGD) with a learning rate of 0.1.
We use λ = 1 in the local updating method Eqn.
For P-MNIST, we train 5 epochs for each task while increasing the number of epochs to 50 for S-CIFAR-10, 100 for both S-CIFARand TinyImageNet regarding their data complexity, as done by works [6, 43].
For P-MNIST and
S-CIFAR-10, we set the batch size as 10.
For S-CIAFR-100 and TinyImageNet, batch size is set to 50.
Following the implementation of ER [11], we set the same batch size for training the current task and the memory.
Note the permutation seeds we use for simulation in P-MNIST are different from the ones used in P-MNIST itself to avoid peeping into test datasets.
More training details and hyperparameter values can be found in the Appendix F.
6.2 Main Results
In Table 1, we compare GPS to ER baselines and the offline oracle on the four vision benchmarks.
We also compare GPS using different simulation techniques.
[Figure]
GPS using permutation performs better GPS using permutation shows improved accuracy compared to ER baselines.
Its performance is close to the performance of the offline oracle solution, which implies it is a good approximation.
We can also see that GPS using permutation performs better than using rotation and blurring, in terms of both accuracy and stability.
The results support our hypotheses on the properties that synthesized tasks should bear, i.e ., similar level difficulties to previous tasks and limited zero-shot transfer ability.
Dynamic memory construction provides stability Besides, we notice that the offline ER oracle, and GPS using different simulation techniques, are more stable than ER baselines as they achieve lower standard deviation on most of the evaluated benchmarks.
We attribute this to the reduced interference from random seeds as we take the global objective into explicit consideration.
6.3 Analysis of Simulation Methods
To further understand why permutation works better than other simulation techniques, we analyze the task t 3 of the S-CIFAR-100 benchmark.
To make fair comparisons with the offline oracle, we train the pseudo-tasks with the same amount of training data and training epochs here.
We plot the curve of global loss w.r.t.
the ratio of ER-Ring-Full in the memory M 3 , 3 (or pseudo memory ˜
M 3 , 3 ), and the forgetting curve of task t 3 after training future tasks (or future pseudo-tasks), as in Fig.
We can see that the rotation induces less forgetting (lower loss) than the real tasks (offline cases) along the sequence, as shown in Fig. 3(b), as rotation creates tasks sequences that bear good zero-shot transfer from the previous tasks.
The pseudo-task sequence created by rotation is therefore too easy such that the switching point of the curve is close to 0 , as shown in the Fig. 3(a), which implies it is similar to an ER-Res static policy.
As for the blurring, the forgetting curve first climbs slowly, as it allows some zero-shot transfer from the previous tasks.
And then, the loss increases dramatically since the task difficulty goes up.
Its pattern of forgetting is quite different from the real tasks (offline case) as shown in the Fig. 3(b).
We also observe that the GPS using permutation has the closest switching point to the offline compared to the rest.
Though permutation creates pseudo-task sequence that result in higher losses than the real task sequence, the pattern of forgetting is similar.
We compute the L1-norm of the offline sampling ratios vs .
permuting-simulated sampling ratios, which are 0.9, 0.7, 1.2, 1.2 for P-MNIST,
S-CIFAR-10, S-CIFAR-100 and TinyImageNet, respectively.
The method selects sampling ratios for other benchmarks as good as that for the P-MNIST, which implies the similarity of pseudo-tasks is not the major factor for the enhanced results.
6.4 Long Task Sequence
We extend the 10-task P-MNIST benchmark to 20 and 40 tasks to create longer task sequences, and make the same comparison on GPS, ER-Oracle and three ER baselines in Fig. 3(c).
[Table]
Longer task sequence requires more careful memory construction The offline solution,
i
[Table]
e .,
ER-Oracle, outperforms the baseline policies by ∼ 5% accuracy when T = 40 .
We attribute the performance gain to the global objective oriented memory construction.
Clearly, for our global objective oriented memory construction, longer task sequence means larger search space of memory construction.
Notice for ER baselines in Fig. 3(c), the standard deviations are larger than those on shorter task sequences, which implies that the larger space of memory construction choices makes a larger performance gap between the worst and the best memory construction.
We also see that GPS solves the problem significantly better than the baselines.
Interestingly, GPS still achieves close performance to the offline solution when the task sequence is long.
6.5 Simulation Time Cost
We show how many extra time, i.e ., pseudo-task generation and pseudo-task training time, GPS adds to the standard ER training.
We compute the time cost of the standard ER training vs .
the extra time from GPS in Table 2(a).
GPS is time efficient We take the asynchronous simulation, which applies a binary search to determine ˜ s j sequentially in O ( T log |M| ) sweeps.
Suppose simulating the training of each pseudotask takes a unit time, each sweep is in O ( T ) .
Then, the total simulation process is in O ( T 2 log |M| ) , which is dependent on the memory buffer size and the number of simulation training epochs.
To ensure efficiency, we train pseudo-tasks with fewer epochs.
We disclose those values for each dataset in Appendix F. When the task sequence is short, from Table 2(a), we can see the simulation time is over ten times less than the standard training time.
When the task sequence is long, we can see the simulation cost grows linearly w.r.t.
the number of tasks, as we restrict the search window from T − j to 10 to prevent the simulation cost increasing quadratically.
6.6 Exploration of Other Local Updating Methods
We show the performance of adopting other local updating methods from the existing ER variants besides Eqn.
(2), together with GPS.
The exemplar base policies we take are from the DER ++ and HAL.
DER ++ leverages knowledge distillation in the episodic memory construction.
More specifically, the DER ++ stores both the network output logits of examples and their ground truth labels in the memory.
HAL selects pivotal learned data points besides random samples to store in the memory.
We change the local updating method from Eqn.
(2) to the local updating method used in
DER ++ or HAL respectively to transplant them into GPS, without any other modifications to the algorithm.
GPS integrates well with advanced ER variants From Table 2(b), we can see the performance of
DER ++ and HAL has been further improved by taking the optimized memory construction for M by GPS, which implies the ability of GPS as a framework to incorporate advanced memory-based continual learning methods.
Besides, as the state-of-the-art method DER ++ outperforms other non-ER methods, GPS+DER ++ naturally outperforms them.
Related Works
Continual Learning Enabling an intelligent agent to learn progressively and adaptively without forgetting old knowledge is a long-standing objective in AI [49, 39].
To combat the catastrophic forgetting problem [30, 18], a few methods have been proposed in continual learning [12, 2, 13].
They usually can be categorized into three classes.
One is the regularization-based methods, which introduce an additional regularization term in the loss function to consolidate old behaviors when learning new tasks [20, 44, 53, 8, 19, 36, 15].
One is the replay methods, which store a tiny amount of old examples in a size-bounded memory or condense previous knowledge in a generative model to generate pseudo samples [26, 46, 1, 9, 6, 11, 40, 1, 24, 47, 51, 7, 35].
The data stored in the buffer would be revisited and trained together with each current training task.
The third is the parameter isolation methods, which usually allocate additional neural resources for new knowledge without constraints on the model size [42, 29, 45, 52].
The memory cost of these methods would therefore scale with the number of tasks.
The ER Family Experience replay falls into the replay method category, which takes a fixed-sized buffer to store old examples.
Existing experience replay variants have adopted the same setup as ER, and focus on refining the local updating method, i.e . how to optimally update model parameters by joint training of current task and examples in memory.
The advanced techniques used to improve local updating step include additional regularization [9], knowledge distillation [5, 6] and selective memory sampling [1, 35].
Distinct to vanilla ER or its variants, which implicitly minimize the global loss of the final model parameters by designing a powerful local updating method, our work focus on directly optimizing the global objective function by creating pseudo-tasks to mimic the catastrophic forgetting for the current task.
Conclusion
In this paper, we propose the dynamic memory construction optimization problem for continual learning under the experience replay setup.
The problem aims at finding the best memory construction strategy to optimize the global objective function in continual learning.
We simplify the problem to a small space by taking three tactics, and find a solution in time complexity O
( T log |M| ) in an offline setup.
We then officially introduce our Global Pseudo-task Simulation (GPS), which provides an approximate solution to the simplified problem under the realistic online setup by creating pseudo-tasks to mimic the future catastrophic forgetting pattern for the current task.
Our empirical results have shown our approach outperforms baselines and can improve the accuracy of existing ER variants [9, 6].
Future Studies We focus on the task- and domain-incremental in this work.
Some future improvements could be extending Global Pseudo-task Simulation to the class-incremental (class-IL) setup.
There are two potential challenges under this setup.
1) the task identity is known.
This could be achieved by triggering the simulation after experiencing a certain amount of data points instead of a task.
2) though the ER-Res and ER-Ring-Full mixed policies are good enough under task and domain
IL, we might involve a complex mixture policies to find the offline oracle under class-IL, where new assumptions are required.
Further, we hope our work could inspire the community to design new datasets closer to the real-world setting.
For example, when task sequences have specific zero-shot transfer patterns.
In such cases, we might first infer the zero-shot transfer pattern from a few data points and then inject the bias into the simulation process.
Acknowledgements
We would like to express our sincere gratitude to Sébastien M. R. Arnold, Robin Jia and Jesse
Thomason from USC for their valuable suggestions on writing.
Appendix
In this appendix, we provide details skipped in the main text.
The content is organized as follows:
• Section A. Detailed algorithms of GPS, including binary search and simulation process.
( c.f . §5.4 of the main text) • Section B. Validation of the switching point existence.
( c.f . §4.3 of the main text) • Section C. Validation on the properties of the simulation methods.
( c.f . §5.2 of the main text) • Section D. Additional experimental results and ablation studies.
( c.f . §6.2, §6.5 and §6.6 of the main text) • Section E. Exploration of new base policies based on curriculum learning, and their performance with GPS.
• Section F. Experimental details and hyperparameters.
( c.f . §6.1 of the main text) • Section G. Algorithms of ER-Res and ER-Ring-Full.
A Detailed Algorithms A.1 Simulation Process
The pseudocode of our simulation process (Fig. 2 in the main text) is listed in Algorithm 1.
We use the notation P 1: i to represent the task distributions from P 1 to P i .
Likewise, we use the notation s 1: i to represent the switching point from s 1 to s i .
The memory construction function BuildM takes as arguments the previous memory, the current task distribution, and an optional current switching point.
If the the switching point is provided, this function internally construct the memory with the given switching point as described in §4; otherwise, it utilizes the described pseudo-memory construction methods as described in §5.
Algorithm
[Table]
A.2 Binary Search
In the global binary search as listed in Algorithm 2.
To increase the robustness of the algorithm, we take a minimum search stride min _ ϵ = 20 , 10 , 40 , 40 and a maximum search stride max _ ϵ = 100 , 20 , 200 , 200 for four benchmarks P-MNIST, S-CIFAR-10, S-CIFAR-100, TingImageNet, respectively.
Also, as we evaluate the continual learning algorithms on the mean accuracy over T tasks, we apply the binary search to find switching point with the highest accuracy but not the lowest loss.
Though lower loss usually implies higher accuracy, directly searching based on accuracy gives us slightly better performance.
A.3 GPS Algorithm
Based on the simulation process and binary search, we describe our Global Pseudo-task Simulation method in Algorithm 3.
Algorithm
Input: Number of tasks T ; Task distributions P 1: i ; Local updating method g ; Current model parameters θ i and current memory M i − 1 ; Search stride ϵ .
Synthesize pseudo-tasks from P i with task distributions.
start ←end ← |M| /i
Set bounds for the stride: ϵ ← max( min _ ϵ, min( max _ ϵ, ϵ ))
Accuracy dictionary: acc _ dict ← ∅ while end − start ≥ ϵ do next ← ( start + end ) /if
next not in acc _ dict then loss, acc ← GlobalSim ( next, ˜ P ( i +1): T , g, θ i , M i − 1 )
acc _ dict ← acc _ dict
∪ { next : acc } else
acc ← acc _ dict
[ next ] end if if next − ϵ not in acc _ dict then left _ loss, left _ acc ← GlobalSim ( next − ϵ, ˜ P
( i +1): T , g, θ i , M i − 1 )
acc _ dict ← acc _ dict ∪ { next − ϵ : left _ acc } else left _ acc ← acc _ dict
[ next − ϵ ] end if if next + ϵ not in acc _ dict then right _ loss, right _
acc ← GlobalSim ( next + ϵ, ˜ P
( i +1): T , g, θ i , M i − 1 )
acc _ dict ← acc _ dict
∪ { next + ϵ : right _ acc } else right _ acc ← acc _ dict
[ next + ϵ ] end if if left _ acc <
acc then end ← next continue else if right _ acc <
acc then start ← next continue elsebreakendif end while s i ← argmin acc ( acc _ dict ) return Switching point:
s i
Algorithm
Input: Number of tasks T ; Task distributions P
i , i ∈ T ; Local updating method g ( · ) .
Initialize parameters θ
Initialize memory M 0 = ∅ i ←while i ≤ T do
Local update: θ i ← g ( θ i − 1 , P i , M i − 1 )
Find switching point: s i ← GlobalBS ( T, P 1: i , g, θ i , M i − 1 , |M| / 5 i )
Build memory: M i ← BuildM
( M i − 1 , s i )
i ← i +end while return Model parameters: θ T
B Validation of the Switching Point Existence
As a validation of our switching point existence, we further show the switching point of other benchmarks in our experiments.
For each benchmark, we plot the global loss L G as a function of a i and select 5 different tasks t i .
Each plot shows clearly the switching point in Fig. 4.
[Figure]
C Validation of the Simulation Method
In this section, we provide the empirical supporting evidences for our hypotheses of the simulation method.
C.1 Task Difficulties
First, we show the task difficulties in the evaluated benchmarks have small variations, as in Table 3.
For P-MNIST, S-CIFAR-100 and TinyImageNet, we evaluate the first 5 tasks end-to-end for simplicity.
For S-CIFAR-10, we evaluate all the tasks end-to-end.
Further, we evaluate the difficulty along the
[Table]
pseudo-task sequence synthesized from the first task of S-CIFAR-100 by permutation, rotation and blurring, we generate 5 tasks for each simulation method.
The results in Table 4 shows permutation and rotation generate tasks with similar difficulties as the original S-CIFAR-100 tasks, while blurring generate tasks with increasing difficulties as the task sequence grows.
C.2 Zero-shot Transfer Ability of Tasks
Next, we explore the zero-shot transfer ability of the pseudo-tasks vs .
the real tasks.
We evaluate the model trained on the first two tasks of S-CIFAR-100 on task sequences different by different simulation methods.
[Table]
Table 5 shows that the permutation pseudo-tasks and the real tasks both allows zero transfer ability, as the random guess accuracy of a 10-class classification is 10%.
Rotation, instead, creates a task sequence that allows nearly perfect zero-shot transfer ability.
Blurring creates a task sequence which allows some zero-shot transfer ability from the beginning
[Table]
but it gradually reduces to a random guess as task difficulty grows.
[Table]
D Additional Experimental Results D.1 Accuracy of GPS with Small Memory Buffer
We also conduct experiments of GPS to evaluate its performance when the memory buffer is relatively small, as shown in Table 6.
With a small size memory buffer, GPS does not show significant improvement.
One reason is the switching point s j is very close to 1, i.e ., taking the pure ER-RingFull policy is good enough.
Another cause is our base policy assumption does not work very well under the small memory buffer size as model becomes more sensitive to points selection under small
M .
[Table]
D.2 Results of GPS with DER ++ , HAL and Baselines
We put complete results of GPS+DER, GPS+DER ++ , GPS+HAL and baselines in Table 7.
Note the
A-GEM [10], iCaRL [37] and GSS [3] use the same memory size as the ER series for fair comparison.
The results stand as a complete empirical support to illustrate that the performance of other ER variants have been improved after using our GPS method.
[Table] [Table]
E New Base Policies based on Curriculum Learning
To further test the power of GPS
[Table]
we substitute the base policies with two novel memory construction methods designed by us based on curriculum learning [16], ER-CurRes and ER-CurRing-Full.
The inspiration of these two methods comes from recent findings that curriculum can help when noisy data are present [50, 31, 41].
We believe data points of future task can be viewed as noisy interference for samples stored in M .
In these two policies, curricular easy points of each task are picked as candidates for M .
E.1 Algorithm
Curricular Easy Samples We rank data examples from easy to hard based on the implicit curricula [50].
Specifically, we first record the learned epochs as an attribute of an example, which is the earliest epoch in training where a model correctly predicts this example for that and subsequent epochs till now.
As the learned epoch is a positive integer attribute, it is defined as a subset of the totally ordered set Z + .
We also record the current loss of each example as another attribute.
The loss attribute is defined as a subset of the totally ordered set R .
The ranking of examples is based on the lexicographical order on the Cartesian product of the two attributes, i.e ., first sorting the examples by the learned epoch attribute, and then ordering examples within the same ranked epoch by their losses.
As a result, each training example of a task would be associated with an unique ranking.
Also, the ranking would be updated after each epoch.
ER-CurRes The ER-CurRes algorithm is shown in Algorithm.
Different from ER-Res which stores examples sampled from the whole distribution P i of a task t i [11], we sample subset of data points from an “easy pool”, i.e . P easy i .
The size is calculated by the dataset size |D i | multiplying a hyperparameter γ , whose value is reported for each evaluation dataset in Section F.
Compared to taking the top few easiest points of each class, sampling from the pool utilizes the benefits of randomness [4, 50].
Suppose we train a total of k epochs of task t i , in order to obtain a smooth transition and the samples based on a more stable curriculum ranking, we take the examples obeying
ER-Res policy ( i.e ., samples from P i ) for the first ⌈ k/ 2 ⌉ epochs, and take the examples obeying
ER-CurRes policy ( i.e ., samples from P easy i ) for the last ⌊ k/ 2 ⌋ epochs.
When we finish training, we replace the examples of
task t
i in the memory which are not from P easy i .
ER-CurRing-Full Likewise, as shown in Algorithm.
5, ER-CurRing-Full follows the ER-Ring-Full strategy in the first ⌈ k/ 2 ⌉ epochs to fill a FIFO memory [11].
After that, we substitute the memory slots with points from the easy pool of each observed class.
In the construction of the easy pool,
Initialize a random easy pool P easy
P for ep ∈ { 1 , ..., k } do for iter ∈
..., |D| /B do
Sample a batch B P from P and a batch B M
M
Update θ with B P ∪ B M if ep ≤ ⌈ k/ 2 ⌉ then
Update M with a probability |M| /N for each examples in B P
N = N +else
Update M with a probability |M| / ( γ ∗ N ) for each examples in B P ∩ P easy
N = N + 1 /γ end if end for
Update P easy : order examples based on the implicit curriculum and select the first γ |D| end for
Select the memory for the current task as M now and the memory for all previous tasks as M past for idx ∈ M now do if idx / ∈ P easy then
Replace the slot in M now with samples from ( P easy − M now ) end if end for
Return Updated θ and M =
M now ∪ M past instead of taking the easiest γ |D| examples as in ER-CurRes, we use the easiest γ |D| /C examples of each class based on the ranking, where C is the number of classes.
E.2 Experimental Results of GPS w/ Cur
The accuracy comparison between GPS w/ Cur and GPS w/ ER-CurRes, ER-CurRing-Full are shown in Table 8.
From the table, we can see GPS w/ Cur outperforms both ER-CurRes and ER-CurRingFull in both datasets.
Besides, GPS with the blending of curriculum policies do not significantly outperform the blending of ER-Ring-Full and ER-Res.
It implies that applying ER-Ring-Full and ERRes as base policies are probably enough for the current benchmarks under the task- and domain-IL setups.
[Table]
Initialize
Reallocate the memory M past for all previous tasks, and allocate the memory M now for the current for e ∈ { 1 , ..., k } do for iter ∈ 1 , ..., |D| /B do
Sample a batch B P from P and a batch B M from M
Update θ with B P ∪ B M if e ≤ ⌈ k/ 2 ⌉ then
Update M now with B P else
Update M now with B P ∩ P easy end if end for Update P easy : order examples based on the implicit curriculum and select the first γ portion of each class end for for idx ∈ M now do if idx / ∈ P easy then
Replace the slot
M now
) end if end for
Return Updated and M =
M now ∪ M past
F Experimental Details F.1 Simulation Details
In experiments, we set the number of examples in each synthesized pseudo-task the same as the size of the memory buffer, i.e ., if |M| = 1000 , we then generate 1000 examples for each pseudo-task.
For computational efficiency, we set the number of training epochs small in the simulated training process.
We train 1 epoch for pseudo-tasks synthesized in the P-MNIST dataset, 5 epochs for pseudo-tasks in
S-CIFAR-10, S-CIFAR-100 and TinyImageNet.
As for the batch size, the optimizer and the learning step during the simulation process, they are all the same as in the real training process.
F.2 Other Hyperparameters
We disclose the experimental hyperparameters values not reported in the main manuscript in Table 9.
In the table, γ in the ‘Cur-’ series methods is the easy pool ratio of the curriculum-based policies as we discussed in Section E, while other symbols refer to the respective methods.
In all the experimental evaluation by accuracy, reported numbers are averaged over 5 runs.
F
.3 Time Measurement
We measure our training and simulation time for each dataset in a single NVIDIA Tesla K80 GPU for fair comparison.
The time we report is the total processing time averaged on 5 runs, assessed in wall-clock time (seconds) at the end of the last task and then converted into minutes.
G ER-Res & ER-Ring-Full Algorithms
We put the algorithms of ER-Res [11] and ER-Ring-Full [11] for a single task in Algorithm 6 and
Algorithm 7 for reference.
[Table]
1: procedure U PDATE M EMORY ( |M| , t, n, B ) 2: j ←3: for ( x, y ) in B do 4:
M ← M 5: if M < |M| then 6:
M .
append ( x, y, t ) 7: else 8: i = randint (0 , n + j ) 9: if i < |M| then 10:
M [ i ] ← ( x, y, t ) 11: end if 12: end if 13: j ← j +14: end for 15: return M 16: end procedure
1: procedure U PDATE M EMORY ( |M| , t, n, B ) 2: for (
) in B do 3:
Divide memory into FIFO stacks M [ y ] , where |M [ y ] | = |M| /t 4:
M [ y ] .
append ( x ) 5: end for 6: return M 7: end procedure