Paper deep dive
AdaHAT: Adaptive Hard Attention to the Task in Task-Incremental Learning
Pengxiang Wang, Hongbo Bo, Jun Hong, Weiru Liu, Kedian Mu
Intelligence
Status: not_run | Model: - | Prompt: - | Confidence: 0%
Entities (0)
Relation Signals (0)
No relation signals yet.
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:Catastrophic forgetting is a major problem in task-incremental learning, where neural networks tend to overwrite previously learned knowledge when trained on new tasks. A number of architecture-based approaches have been proposed to address this problem. However, the architecture-based approaches suffer from another problem related to network capacity when the networks learn long task sequences: As a network is trained on an increasing number of new tasks in a long task sequence, a growing proportion of active parameters becomes static to prevent forgetting of previously learned knowledge. In this paper, we propose Adaptive Hard Attention to the Task (AdaHAT) with an adaptive attention mechanism which allows adaptive updates to static parameters by taking into account the information about previous tasks on both the importance of these parameters to previous tasks and the current network capacity. Based on this idea, we develop a new neural network architecture incorporating our proposed AdaHAT mechanism. AdaHAT extends an existing architecture-based approach, Hard Attention to the Task (HAT), to better support task-incremental learning over long task sequences. We conduct experiments on a number of datasets and compare AdaHAT with task-incremental learning baselines including HAT. Our experimental results show that AdaHAT achieves better average performance across tasks than these baselines, especially on long task sequences, demonstrating the benefits from balancing the trade-off between stability and plasticity of a network when learning such sequences of tasks, alleviating the network capacity problem. Our code is available at this http URL.
Tags
Links
- Source: https://arxiv.org/abs/2608.01252v1
- Canonical: https://arxiv.org/abs/2608.01252v1
Trouble viewing inline? Open PDF directly →
Full Text
53,323 characters extracted from source content.
Expand or collapse full text
11institutetext: School of Mathematical Sciences, Peking University, Beijing, China 11email: wangpengxiang@stu.pku.edu.cn, mukedian@math.pku.edu.cn 22institutetext: Population Health Sciences Institute, Newcastle University, Newcastle, UK 22email: hongbo.bo@newcastle.ac.uk 33institutetext: School of Engineering Mathematics and Technology, University of Bristol, Bristol, UK 33email: weiru.liu@bristol.ac.uk 44institutetext: School of Computing and Creative Technologies, University of the West of England, Bristol, UK 44email: Jun.Hong@uwe.ac.uk AdaHAT: Adaptive Hard Attention to the Task in Task-Incremental Learning Pengxiang Wang Hongbo Bo Jun Hong Weiru Liu Kedian Mu (✉) Abstract Catastrophic forgetting is a major problem in task-incremental learning, where neural networks tend to overwrite previously learned knowledge when trained on new tasks. A number of architecture-based approaches have been proposed to address this problem. However, the architecture-based approaches suffer from another problem related to network capacity when the networks learn long task sequences: As a network is trained on an increasing number of new tasks in a long task sequence, a growing proportion of active parameters becomes static to prevent forgetting of previously learned knowledge. In this paper, we propose Adaptive Hard Attention to the Task (AdaHAT) with an adaptive attention mechanism which allows adaptive updates to static parameters by taking into account the information about previous tasks on both the importance of these parameters to previous tasks and the current network capacity. Based on this idea, we develop a new neural network architecture incorporating our proposed AdaHAT mechanism. AdaHAT extends an existing architecture-based approach, Hard Attention to the Task (HAT), to better support task-incremental learning over long task sequences. We conduct experiments on a number of datasets and compare AdaHAT with task-incremental learning baselines including HAT. Our experimental results show that AdaHAT achieves better average performance across tasks than these baselines, especially on long task sequences, demonstrating the benefits from balancing the trade-off between stability and plasticity of a network when learning such sequences of tasks, alleviating the network capacity problem. Our code is available111pengxiang-wang.com/projects/continual-learning-arena. 1 Introduction One of the key features of human intelligence is the ability to learn continually and adapt to new information over time. One of the fundamental challenges faced by deep neural networks in continual learning is catastrophic forgetting [15, 17, 3], which results in drastic performance degradation on previous tasks as a network is sequentially trained on new information. Continual learning, and its scenario task-incremental learning, aim to address this problem by aiming to learn and accumulate knowledge over a sequence of tasks without catastrophic forgetting [9]. To overcome catastrophic forgetting in task-incremental learning, various strategies have been proposed. Most of these strategies adopt the idea of leveraging certain forms of information about previous tasks and incorporating them into the learning process for new tasks to prevent forgetting previously learned knowledge. For example, replay-based approaches mitigate forgetting by storing parts of previous task data, which replay algorithms use to consolidate previous knowledge [12, 20, 1]; regularization-based approaches introduce regularization terms constructed using information about previous tasks into the loss function when training new tasks [11, 8, 25, 10, 16]. Architecture-based approaches have been proposed to exploit the inherent nature of parameter separability within the architecture of neural networks, focusing on reducing representational overlap in the network. The core idea in these approaches is to allocate parameters in different parts of the network to different tasks, to keep the parameters learned for previous tasks from being significantly changed when learning new tasks [2, 14, 13, 19, 24]. Therefore, they are also referred to as parameter isolation methods [9]. An important consideration in these approaches is the trade-off between stability and plasticity of the network, where stability is reflected in performance over learned tasks while plasticity is reflected in saving network capacity by keeping parts of the network active for new tasks [23]. A recent architecture-based approach to reduce representational overlap is the task-based hard attention mechanism called Hard Attention to the Task (HAT) [19]. HAT learns layer-wise attention vectors (masks) for each task, concurrently to learning network parameters, to protect parameters that are important to previous tasks. When learning new tasks, HAT freezes parameters allocated to previous tasks, thus preventing forgetting what has been learned. Specifically, HAT achieves this behavior through adjusting gradients during the training process to manipulate the updates to the parameters directly. However, as the number of tasks increases, network capacity is rapidly saturated, which greatly reduces the proportion of remaining active parameters for new tasks. We refer to this as the network capacity problem. Here, HAT overemphasizes stability at the cost of reduced plasticity, while other categories of continual learning approaches typically exhibit the opposite tendency. In this paper, we propose an extension to the task-based hard attention mechanism proposed in HAT. Following the spirit of HAT, we propose a new mechanism that introduces adaptive attention to the task, which allows adaptive updates to those static network parameters that have been allocated to previous tasks when learning new tasks, taking into account the information about previous tasks on both the importance of these parameters to previous tasks and the current network capacity. These adaptive parameter updates help to reuse, in a measured way, parts of the network that have been made static for previous tasks. We call our proposed mechanism Adaptive Hard Attention to the Task (AdaHAT). AdaHAT has three distinctive characteristics: 1. It balances the trade-off between stability and plasticity of the network, i.e., between protecting important parameters to previous tasks and preserving network capacity for new tasks; 2. It particularly suits for learning long task sequences; 3. It is an adaptive process to update previously static parameters, based on both their importance to previous tasks and network capacity usage. For instance, when the network capacity is insufficient, larger updates are allowed to parameters that have been allocated to fewer previous tasks, hence preserving more network capacity by compromising only a small amount of forgetting on previous tasks. We implement AdaHAT, conduct experiments on a number of datasets and compare it with a number of task-incremental learning baselines, particularly including HAT which AdaHAT extends. Our experimental results show that AdaHAT achieves better average performance across tasks than these baselines, especially on long task sequences, demonstrating the benefits from balancing the stability-plasticity trade-off of a network when learning such sequences of tasks. This paper makes the following contributions: 1. We propose AdaHAT mechanism, which allows adaptive updates to previously static parameters in a neural network, alleviating the problem of insufficient network capacity when learning long task sequences; 2. We develop a neural network architecture based on the architecture developed in HAT [19], integrating our proposed task-based attention mechanism for adaptive parameter updating in the network while retaining the spirit of hard attention to the task proposed in HAT; 3. Our experimental results show that, while slightly causing forgetting, AdaHAT improves the average performance across tasks after the network has reached its capacity limit, which effectively balances the stability-plasticity trade-off in continual learning. 2 Related Work Task-incremental learning is a continual learning scenario where the algorithm learns a sequence of distinct tasks in an incremental manner [22]. In this scenario, it is crucial to balance the stability-plasticity trade-off to ensure the optimal model performance across all tasks [23]. Catastrophic forgetting is a major problem in task-incremental learning, where neural networks tend to overwrite knowledge learned in previous tasks when trained on new tasks. Major efforts have been focused on developing various mechanisms to prevent the network from catastrophic forgetting, often leveraging certain forms of information about previous tasks [23]. In replay-based approaches, parts of the data from previous tasks are stored and replayed during training on new tasks to mitigate forgetting. Examples include GEM [12], DGR [20], and DER [1]. In regularization-based approaches, forgetting is mitigated by introducing regularization terms into the loss function, usually constructed from the information about previous tasks. Examples include LwF [11], EWC [8], SI [25], IMM [10], and VCL [16]. These approaches aim to inject stability into the network in their forgetting prevention mechanisms, but still generally lean towards plasticity in the trade-off. Architecture-based approaches adopt distinctly different strategies that overemphasize stability, shifting the trade-off towards stability instead. They allocate different parts of a neural network to different tasks, i.e., specifying task-specific parameters, which leverages the inherent separability of neural network architectures. One strategy develops incrementally parallel subnetworks to learn the sequence of tasks, exemplified by Progressive Neural Networks [18]. Other strategies allocate the parameter space within a fixed (sometimes dynamically expanded when needed) network architecture, with the allocation determined either by a set of rules, such as PackNet [14], or by trainable masks over the architecture trained along with network parameters, such as Piggyback [13], HAT [19], CPG [5], and SupSup [24]. Architecture-based approaches generally suffer from the network capacity problem because they preserve and freeze task-specific parameters for previous tasks. In this case, the network can achieve maximal stability and the best performance when there is sufficient capacity, but has to face drastic performance degradation on new tasks when capacity runs out. In other words, they sacrifice learning plasticity for potential future tasks to maintain the stability for previous tasks [23]. To alleviate the network capacity problem, many architecture-based approaches introduce measures to carefully control the network capacity usage, with mechanisms such as sparsity regularization [19], which can sometimes in turn limit their ability to learn current tasks [23]. Others gain additional capacity resources by breaking the assumption of the fixed parameter space: some allow dynamically expanding the network when capacity runs out as more new tasks arrive. Some approaches like Progressive Neural Networks [18] even expand the network every time when a new task arrives, causing progressively linear increasing computation and memory cost. Additionally, most architecture-based approaches use many hyperparameters to control their network capacity usage, usually without directly leveraging information about previous tasks. These hyperparameters need to be tuned manually to determine how much capacity should be allocated to new tasks. For example, PackNet uses a pruning ratio to allocate a fixed proportion of network parameters to new tasks [14]. HAT requires manual tuning the hyperparameter smaxs_max, where larger values provide more stability for previous tasks, and smaller values provide more plasticity for new tasks [19]. However, in real-world continual learning scenarios, one does not know how many new tasks will arrive [9], or may even encounter an infinite sequence of tasks, making proper hyperparameter selection difficult. Even if it is known beforehand and the hyperparameters are well chosen for these tasks, network capacity can still become insufficient when additional tasks arrive, and the network capacity problem reappears. Network capacity is a critical factor affecting learning plasticity when incrementally learning long task sequences [9]. To address this problem, we need to balance the stability-plasticity trade-off as well as prevent catastrophic forgetting at the same time. In this paper, we propose a new adaptive task-based attention mechanism to balance the trade-off in architecture-based approaches, enabling the adaptive allocation of network capacity with taking into account the information about previous tasks. Our proposed mechanism, in particular, alleviates the problem of lacking plasticity when incrementally learning long task sequences. 3 Task-Incremental Learning with Adaptive Hard Attention to the Task In this section, we present a new approach for task-incremental learning, our proposed adaptive attention mechanism called Adaptive Hard Attention to the Task (AdaHAT), to balance the trade-off between stability and plasticity. Our proposed mechanism extends the mechanism called Hard Attention to the Task (HAT) proposed in [19]. In the task-incremental learning scenario, a sequence of tasks t=1,⋯,Nt=1,·s,N, arrive at a neural network in an incremental manner, with each task associated with dataset Dt=xt,ytD^t=\x^t,y^t\. The objective of task-incremental learning for the network is to learn the task sequence, preventing performance degradation on previous tasks when learning new tasks, and eventually achieve better performance across all tasks [9]. To achieve this objective, the stability-plasticity trade-off needs to be balanced properly. We adopt the hard attention to the task mechanism proposed in HAT, in which layer-wise attention vectors (masks) mltm^t_l with binary values are learned to pay hard attention to the units in each layer l=1,⋯,L−1l=1,·s,L-1 for a new task t. The attention vectors are gated from layer-wise task embeddings lte_l^t with real values: lt=σ(slt),m_l^t=σ (se_l^t ), (1) where s is a positive scaling factor and σ(⋅)σ(·) denotes the sigmoid gate function. The attention vectors are learned instead of tuned, as the task embeddings are trained along with network parameters. These binary attention vectors determine which part of the network is allocated to the task. We use Mt M^t to denote all the attention vectors to the task t, Θ to denote the parameter space, therefore Θt ^t, parameters in Θ allocated to task t, are those masked by Mt M^t. When training on a new task t, HAT conditions gradients in the backward pass according to cumulative attention vectors ml≤tm^≤ t_l from all previous tasks. The cumulative attention vectors are recursively computed by ml≤t=max(mlt,ml≤t−1)m^≤ t_l= (m^t_l,m^≤ t-1_l ) (2) after learning task t, using element-wise maximum222ml≤0m^≤ 0_l starts with all zeros to compute ml≤1m^≤ 1_l.. This preserves the attention values for units in the network that are important to previous tasks, and allows these preserved values to condition network training on the new tasks. To condition training on the new task t, HAT modifies the gradient of the parameter θl,ij _l,ij connecting the j-th unit in layer l−1l-1 to the i-th unit in layer l, with a parameter-wise adjustment rate al,ija_l,ij: gl,ij′=al,ij⋅gl,ij,al,ij∈0,1,g _l,ij=a_l,ij· g_l,ij,\ a_l,ij∈\0,1\, (3) where gl,ijg_l,ij is the gradient of parameter θl,ij _l,ij, and al,ij=1−min(ml,i<t,ml−1,j<t)a_l,ij=1- (m^<t_l,i,m^<t_l-1,j ) (4) marks the hard clipping of the gradient, computed as the reverse of the minimum of the two cumulative attention values, which results in binary values again. This means, those parameters become static without updates when the units connected at both ends are masked by the cumulative attention vectors, as their gradients are hard clipped. As more tasks arrive, more active parameters become static, gradually taking up more network capacity, hence reducing learning plasticity for new tasks. To address this network capacity problem, a regularization term explicitly controlling mask sparsity is employed in HAT to promote higher compactness of the masks and lower network capacity usage: ℒ′(f(xt),yt,Mt,M<t)=ℒ(f(xt),yt)+cR(Mt,M<t),L (f(x_t),y_t, M^t, M^<t )=L(f(x_t),y_t)+cR ( M^t, M^<t ), (5) R(Mt,M<t)=∑l=1L−1∑i=1Nlml,it(1−ml,i<t)∑l=1L−1∑i=1Nl(1−ml,i<t),R ( M^t, M^<t )= _l=1^L-1 _i=1^N_lm_l,i^t (1-m_l,i^<t ) _l=1^L-1 _i=1^N_l (1-m_l,i^<t ), (6) where c>0c>0 denotes the regularization coefficient and NlN_l denotes the number of units in layer l. This, to a certain extent, helps alleviate the network capacity problem. However, the network capacity will eventually run out, as parameters will become permanently static once they are learned to be allocated to previous tasks. As shown in an experiment illustrated in Figure 0(a), the cumulative attention vector of certain layer is rapidly occupied by value 11 as the network is trained on new tasks, which means the network rapidly exhausts its available parameter space, leading to insufficient network capacity for the algorithm to allocate parameters to new tasks, hence significantly affecting the performance of the network on new tasks. (a) Evolution of the cumulative attention vector to previous and current tasks for the first fully-connected layer (fc1) in a MLP architecture, represented by mfc1≤tm^≤ t_fc1, with network parameters allocated to the tasks highlighted in black. (b) Comparison of HAT and AdaHAT in the evolution of gradient adjustment rates for network parameters (represented as circles). Hard gradient clipping in HAT binarizes parameters into static (orange) and active (white) states, whereas soft gradient clipping in AdaHAT adaptively sets adjustment rates between 0 and 1 based on both parameter importance (the number of rounded rectangles enclosing a parameter) and network sparsity. 3.1 The AdaHAT Algorithm: Adaptive Parameter Updating with Summative Attention to Previous Tasks Following the spirit of the hard attention to the task mechanism proposed in HAT [19], in order to address the network capacity problem in HAT when learning long task sequences, we propose a new adaptive parameter updating algorithm AdaHAT based on HAT. We propose to replace the cumulative attention vectors used in HAT with our new summative attention vectors, computed as follows: ml≤t,sum=mlt+ml≤t−1,sum.m^≤ t,sum_l=m^t_l+m^≤ t-1,sum_l. (7) The network capacity problem in HAT can be alleviated by allowing adaptive updates to parameters in the network that have become static for previous tasks. As shown in Eq. (3), hard gradient clipping is the root cause of this problem: parameters allocated to previous tasks are strictly and permanently frozen when learning new tasks, leaving no room for future tasks to encode their knowledge in them. In AdaHAT, we therefore propose soft clipping of gradients as follows to release some capacity from these static parameters for previous tasks: gl,ij′=al,ij⋆⋅gl,ij,al,ij⋆∈[0,1],g _l,ij=a _l,ij· g_l,ij,\ a _l,ij∈[0,1], (8) where al,ij⋆a _l,ij denotes the adjustment rate of AdaHAT. Unlike the binary al,ija_l,ij in HAT, al,ij⋆a _l,ij ranges from 0 to 1, soft clipping the gradient gl,ijg_l,ij. This allows controlled updates to parameter θl,ij _l,ij. Two pieces of information about previous tasks are crucial for gradient adjustment and for determining how much network capacity should be released during training: parameter importance to previous tasks and current network capacity usage. We therefore design our adjustment rate to adapt to both. In the following, we first define two corresponding measures: parameter importance and network sparsity, and then incorporate them into the formulation of the adjustment rate. Parameter Importance. In HAT, cumulative attention vectors defined in Eq. (2) are used to preserve parameters that are important to previous tasks. Larger cumulative attention values in these vectors indicate greater importance of the corresponding parameters; therefore, smaller updates are made to them when learning new tasks. However, this binary measure of parameter importance is often insufficiently discriminative. In AdaHAT, we replace the cumulative attention vectors with our new measure of parameter importance, called summative attention vectors, as defined in Eq. (7). For each parameter θl,ij _l,ij, we still compute the minimum of the summative attention values of the connected units at both ends, min(ml,i<t,sum,ml−1,j<t,sum) (m^<t,sum_l,i,m^<t,sum_l-1,j ), as the importance of that parameter to previous tasks. This value ranges from 0 to t−1t-1, and therefore contains richer information about previous tasks. A higher summative attention value indicates that the parameter is allocated to more previous tasks, so smaller updates should be made to it when learning new tasks. For parameters with lower importance, more of their space can be released. In short, the adjustment rate should be negatively correlated with this parameter importance value. Network Sparsity. The regularization term in HAT reflects the compactness of binary masks, which we use as a measure of network sparsity. As indicated by Eq. (6), larger regularization values indicate that, when learning new tasks, the algorithm is paying more attention to allocating the active parameter space that has not been allocated to previous tasks. In this case, there is less need to update parameters that have already become static for previous tasks. Furthermore, this regularization value is closely related to current network capacity usage. In general, when a smaller proportion of parameters in the network is static, the regularization value tends to be larger, because more active parameters remain available for allocation. In such cases, network capacity is still sufficient, so the algorithm should avoid hastily releasing parameter space allocated to previous tasks and should instead focus on learning from currently active parameters. Therefore, the adjustment rate should be negatively correlated with this sparsity regularization value. By incorporating network sparsity information into the adjustment rate, AdaHAT is designed to approximate HAT in early tasks as closely as possible: it applies smaller updates through a lower adjustment rate before the network reaches its capacity limit. Only when capacity becomes insufficient does it start making larger updates to parameters allocated to previous tasks. By retaining maximal stability for previous tasks before sacrificing plasticity for new tasks, AdaHAT follows the spirit of HAT and preserves its stability benefits while introducing adaptive behavior. We now define the AdaHAT adjustment rate by incorporating both pieces of information about previous tasks: al,ij⋆=rlmin(ml,i<t,sum,ml−1,j<t,sum)+rl,rl=αR(Mt,M<t)+ϵ,a _l,ij= r_l (m^<t,sum_l,i,m^<t,sum_l-1,j )+r_l,\ r_l= αR ( M^t, M^<t )+ε, (9) where α>0α>0 is a hyperparameter that controls the overall intensity of gradient adjustment. The constant ϵε is set to a small value to avoid division by zero. Note that, for active parameters, the adjustment rate is 1 because their parameter importance (summative attention) value is 0; therefore, soft clipping also applies only to gradients of parameters allocated to previous tasks. As shown by the formulation, the adjustment rate is negatively correlated with both parameter importance and network sparsity. These two pieces of information jointly control gradient adjustment and adaptively manage network capacity usage based on previous tasks and the current learning state. We present an illustration of how the adjustment rates evolve as new tasks arrive in Figure 0(b) and summarize the AdaHAT algorithm in Algorithm 1. Input: task sequence Dt,t=1,2,3,⋯D^t,t=1,2,3,·s; adjustment intensity α; HAT hyperparameters c, smaxs_max; learning rate η. Output: trained network parameters Θ shared by all tasks; hard attention vectors (binary mask) Mt M^t for each task t=1,2,3,⋯t=1,2,3,·s 1exInitialize: task embeddings elte^t_l from (0,1)N(0,1); summative and cumulative attention vectors ml≤0,summ^≤ 0,sum_l, ml≤0m^≤ 0_l both to zeros. 1exfor task t=1,2,⋯t=1,2,·s do for each training step do Forward propagate input through the network under mask mltm^t_l using Eq. (1); Compute current network sparsity R using Eq. (6); Compute loss ℒ′L using Eq. (5) and backpropagate gradients gl,ijg_l,ij of network parameters θl,ij _l,ij and gradients of task embeddings elte^t_l; Compute adjustment rate al,ij⋆a _l,ij using Eq. (9); Soft-clip the gradients to gl,ij′g _l,ij using Eq. (8) with the adjustment rate; update θl,ij _l,ij using adjusted gradients gl,ij′g _l,ij and update elte^t_l with learning rate η; Compute the summative and cumulative attention vectors ml≤t,summ^≤ t,sum_l, ml≤tm^≤ t_l of task t using Eq. (7) and Eq. (2). Algorithm 1 Adaptive Hard Attention to the Task (AdaHAT) 4 Experiments In this section, we first introduce our experimental setup and metrics for performance, stability-plasticity trade-off and network capacity usage. We then present our experimental results of the performance on long task sequences and how AdaHAT achieves it by balancing stability-plasticity trade-off. Finally, we present ablation study of two pieces of information and hyperparameter study. Our findings demonstrate that the proposed adaptive parameter updating approach, which takes into account both the parameter importance and the current network capacity usage, is effective. It can make adaptive gradient adjustments when learning new tasks, within a very small adjustment rate. 4.1 Experimental Setup Task Sequences. AdaHAT aims to address the problem of insufficient network capacity when learning long sequences of tasks. Our experiments are conducted on long task sequences containing 20 tasks, which are longer than those commonly used in conventional continual learning experiment setups, where their task sequences usually contain fewer than 10 tasks. This long task sequence setting allows us to better observe how architecture-based approaches behave once the network reached its capacity limit and how performance evolves afterward, thereby exposing the network capacity problem more clearly. We also conduct experiments on much longer sequences of up to 50 tasks, which further increases the difficulty of the setting. Data. We use the permuted version of MNIST [21] and the split version of CIFAR-100 [6] as our experiment datasets. We do not use permuted versions of CIFAR-10 and CIFAR-100 because, under long task sequences, they are overly challenging for most baselines, resulting in uniformly low performance and making meaningful comparisons difficult. In addition, Split MNIST and Split CIFAR-10 are unsuitable for our setting because their 10 classes cannot be partitioned into long task sequences (e.g., 20 tasks). Baselines. To evaluate the performance of AdaHAT, we compare it with the following baselines: • Finetuning: standard gradient-based training with no mechanism to prevent forgetting [3]; • Freezing: Stops learning after the first task; • LwF: Learning without Forgetting [11]; • EWC: Elastic Weight Consolidation [8]; • HAT: Hard Attention to the Task [19]. We also compare AdaHAT with other gradient adjustment strategies. These strategies adjust gradients under the HAT architecture in naive or less meaningful ways (randomly or uniformly), without guidance by information about previous tasks: • HAT-random: HAT with an adjustment rate of random value between 0 and 1, where al,ija_l,ij in Eq. (3) is replaced by rand(0,1),if 1−min(ml,i<t,ml−1,j<t)=0,1,otherwise. casesrand(0,1),&if 1- (m^<t_l,i,m^<t_l-1,j )=0,\\ 1,&otherwise. cases • HAT-const-alpha: HAT with a fixed adjustment rate of constant value α (equals to α in Eq. (9)), where al,ij=α,if 1−min(ml,i<t,ml−1,j<t)=0,1,otherwise.a_l,ij= casesα,&if 1- (m^<t_l,i,m^<t_l-1,j )=0,\\ 1,&otherwise. cases • HAT-const-1: HAT with a fixed adjustment rate of constant value 11, meaning that no gradient flow is blocked by previous task masks during backpropagation. The subnetwork for the current task is completely free to learn, regardless that it contains parameters allocated to previous tasks. Evaluation Metrics. We evaluate AdaHAT and the baselines using 4 metrics: performance, stability, plasticity and network capacity usage. We compute Average Accuracy (A) [23] and Forgetting Ratio (FR) [19] on each dataset over all tasks, which are the main performance metrics in task-incremental learning. In addition, to characterize the stability-plasticity trade-off and reveal whether each approach tends to favor stability, plasticity, or a more balanced behavior, we report Backward Transfer (BWT) [23] and Forward Transfer (FWT) [23] to measure stability and plasticity, respectively. Let at,Na_t,N denote the accuracy of the test model on dataset DtD^t after learning task N, at,NJa^J_t,N denote the accuracy on dataset DtD^t of a randomly-initialized reference model jointly trained on ∪τ=1NDτ _τ=1^ND^τ, atIa^I_t and atRa^R_t denote the accuracy of a randomly-initialized reference model independently trained on DtD^t and a random stratified model, respectively. The metrics are defined as follows [23]: AAN=1N∑t=1Nat,N,A_N= 1N _t=1^Na_t,N, (10) FRN=1N∑t=1Nat,N−atRat,NJ−atR−1,FR_N= 1N _t=1^N a_t,N-a^R_ta^J_t,N-a^R_t-1, (11) BWTN=1N−1∑t=1N−1(at,N−at,t),BWT_N= 1N-1 _t=1^N-1 (a_t,N-a_t,t ), (12) FWTN=1N−1∑t=2N(at,t−atI).FWT_N= 1N-1 _t=2^N (a_t,t-a^I_t ). (13) Each experiment is repeated 5 times, and we report the mean and standard deviation for each metric as percentages. We propose to measure network capacity usage by the relative degree to which parameters are allowed to be updated, as reflected by the adjustment rates333AdaHAT’s adjustment rates are denoted as al,ij⋆a _l,ij.: NC=1∑l,i,j1∑l,i,jal,ij.NC= 1Σ _l,i,j1 _l,i,ja_l,ij. (14) The values of NC ranges from 0 to 11, where 1 indicates that all parameters can be updated freely with no adjustment to their gradients, and 0 indicates that all gradients are set to zeros and no parameter is allowed to be updated. Networks. For experiments on Permuted MNIST, we use a fully-connected (MLP) network architecture including 3 hidden layers with dimensions 256, 100, and 64 as the feature extractor. For the experiments on Split CIFAR-100, we use ResNet-18 [4] as the feature extractor. Task embeddings are integrated into each layer to generate task-based attention vectors [19]. Rectified linear unit is used as the activation function. As this is a task-incremental learning scenario, each task has its own output head which is a linear output layer, and the number of heads increases as new tasks arrive. All layers are randomly initialized, except for task embeddings lte^t_l, which are initialized from a standard normal distribution (0,1)N(0,1). Hyperparameters and Training Details. We set the adjustment intensity α in Eq. (9) to 10−610^-6, as discussed in Section 4.4. ϵε in Eq. (9) is set to 0.10.1. Since the experiments are intended to study the network after it has reached the capacity limit, the hyperparameter smaxs_max in HAT is set to a large value of 400400; c is set to 0.10.1. All models are trained using the Adam optimizer [7] with a learning rate of 0.0010.001. We apply gradient clipping with a threshold of 0.001 and weight decay with a coefficient of 0.00035 to all approaches except those based on the HAT architecture, since gradient clipping and weight decay are incompatible with HAT. We train for 2 and 20 epochs for each task in Permuted MNIST and Split CIFAR-100. The batch sizes are set to 128 and 64, respectively. Training for Permuted MNIST is conducted on local CPUs, whereas training for Split CIFAR-100 is conducted on a server cluster equipped with NVIDIA RTX A4000 GPUs (16 GB VRAM). Our code is implemented as an open-source Python package for continual learning research444pengxiang-wang.com/projects/continual-learning-arena. 4.2 Main Results and Analysis Table 1: Results on performance and stability-plasticity trade-off metrics (mean ± std) of different approaches on the two datasets (20 tasks). Dataset Approach A(↑ ) FR (↑ ) BWT FWT Permuted MNIST Finetuning 32.62±1.6032.62± 1.60 −73.78±1.84-73.78± 1.84 −68.10±1.68-68.10± 1.68 0.10±0.040.10± 0.04 Freezing 14.73±0.4814.73± 0.48 −94.04±0.70-94.04± 0.70 0.00±0.000.00± 0.00 −87.13±0.53-87.13± 0.53 LwF 26.95±1.8026.95± 1.80 −80.35±2.08-80.35± 2.08 −72.59±1.91-72.59± 1.91 −0.04±0.04-0.04± 0.04 EWC 52.25±2.4652.25± 2.46 −51.38±2.83-51.38± 2.83 −42.04±2.67-42.04± 2.67 −8.86±0.09-8.86± 0.09 HAT 67.64±1.2767.64± 1.27 −33.70±1.46-33.70± 1.46 −0.11±0.18-0.11± 0.18 −30.54±0.27-30.54± 0.27 HAT-random 66.43±1.2166.43± 1.21 −35.10±1.39-35.10± 1.39 −0.27±0.49-0.27± 0.49 −1.47±0.05-1.47± 0.05 HAT-const-alpha 68.08±1.1868.08± 1.18 −33.20±1.36-33.20± 1.36 −1∗e−3±0.00-1*e^-3± 0.00 −1.39±0.04-1.39± 0.04 HAT-const-1 48.83±4.3548.83± 4.35 −55.14±5.02-55.14± 5.02 −49.68±4.40-49.68± 4.40 −3.14±0.07-3.14± 0.07 AdaHAT 79.90±2.4079.90± 2.40 −19.43±2.76-19.43± 2.76 −14.68±2.48-14.68± 2.48 −2.49±0.06-2.49± 0.06 Split CIFAR-100 Finetuning 24.34±0.7324.34± 0.73 −91.66±1.32-91.66± 1.32 −54.00±1.00-54.00± 1.00 2.61±0.322.61± 0.32 Freezing 23.22±0.9623.22± 0.96 −94.73±2.13-94.73± 2.13 0.00±0.000.00± 0.00 −57.53±1.20-57.53± 1.20 LwF 34.56±0.9434.56± 0.94 −70.91±2.05-70.91± 2.05 −48.03±1.01-48.03± 1.01 4.23±0.424.23± 0.42 EWC 30.23±1.6130.23± 1.61 −79.84±3.13-79.84± 3.13 −54.05±1.28-54.05± 1.28 −9.80±1.92-9.80± 1.92 HAT 32.44±1.5832.44± 1.58 −74.71±3.37-74.71± 3.37 −45.59±1.49-45.59± 1.49 −18.75±0.94-18.75± 0.94 HAT-random 31.41±1.2931.41± 1.29 −76.98±2.45-76.98± 2.45 −48.80±1.33-48.80± 1.33 −7.18±1.14-7.18± 1.14 HAT-const-alpha 32.16±2.4832.16± 2.48 −75.04±5.16-75.04± 5.16 −44.49±2.57-44.49± 2.57 −5.45±0.82-5.45± 0.82 HAT-const-1 32.40±1.4032.40± 1.40 −75.58±3.08-75.58± 3.08 −48.80±1.72-48.80± 1.72 −7.14±1.12-7.14± 1.12 AdaHAT 38.74±2.2438.74± 2.24 −62.37±4.64-62.37± 4.64 −42.11±2.02-42.11± 2.02 −5.49±0.57-5.49± 0.57 We present the main experimental results on sequences of 20 tasks in Table 1. Our proposed approach, AdaHAT, achieves the best overall continual learning performance in terms of A and FR across all datasets, outperforming HAT and other baseline approaches. This demonstrates the superiority of AdaHAT for task-incremental learning on long task sequences. We observe that many baseline approaches exhibit extreme BWT and FWT values. Finetuning, LwF, and EWC tend to favor plasticity, showing relatively low BWT and high FWT, whereas Freezing and HAT tend to favor stability, showing relatively high BWT and low FWT, both of which demonstrate an imbalanced stability-plasticity trade-off. AdaHAT, by contrast, maintains relatively balanced BWT and FWT values, with neither being excessively high nor low, indicating a more balanced stability-plasticity trade-off. Together with the A and FR results, it suggests that stronger overall performance is often associated with an effective balance between BWT and FWT. Therefore, balancing the stability-plasticity trade-off is important for achieving the objective of continual learning, and AdaHAT is better at this. For the HAT variants with other gradient adjustment strategies, we observe that almost none of them outperform HAT itself, let alone AdaHAT. These approaches apply gradient adjustment in a manner similar to AdaHAT, in that way they allow parameters allocated to previous tasks to be updated, but without proper guidance by information about previous tasks. This indicates that the gradient adjustment must be properly guided in order to play a beneficial role; without being guided by meaningful information about previous tasks, it can even lead to performance degradation. One notable example is HAT-const-1, which allows full parameter updates and shifts the trade-off heavily towards plasticity as reflected by its low BWT, likely contributing to its poor A and FR performance. Overall, these findings suggest that the two pieces of information about previous tasks incorporated in AdaHAT are crucial. We discuss their individual contributions in Section 4.3. (c) Evolution of A (mean) over the task sequence for different approaches on longer sequences of tasks (50 tasks, Permuted MNIST). (d) Evolution of NC over training iterations for different HAT variants on longer sequences of tasks (50 tasks, Permuted MNIST). Longer Task Sequences. To evaluate AdaHAT in a more challenging setting, where the network capacity problem becomes more severe, we conduct experiments on a much longer sequence of 50 tasks on Permuted MNIST. The performance evolution of AdaHAT and the baseline approaches over the task sequence is shown in Figure 0(c). HAT demonstrates slightly better performance before 8 tasks, as it mitigates forgetting by strictly freezing the parameters allocated to previous tasks. However, the performance curve of HAT reaches a turning point at around the 8th task and then drops drastically. This corresponds exactly to Figure 0(a), where HAT has nearly exhausted its active parameter space and the network capacity problem begins to take effect. By contrast, AdaHAT maintains a clear advantage over HAT and the other baselines after this turning point. This is because AdaHAT releases part of the allocated network capacity to make room for future task learning, thereby alleviating the network capacity problem and improving the average performance across tasks. These results further demonstrate the superiority of AdaHAT for continual learning on long task sequences. Furthermore, we observe that although AdaHAT does not outperform HAT before 8 tasks, it behaves very closely to HAT. This validates the role of the network sparsity information: before network capacity is exhausted, it encourages AdaHAT to approximate HAT by restricting updates to parameters allocated to previous tasks to a small scale through smaller adjustment rates, thereby mitigating early forgetting and improving early-stage performance. This finding supports the discussion in Section 3.1. Network Capacity Usage. We plot the evolution of Network Capacity (NC) usage over training iterations under 50 tasks, Permuted MNIST (seed 1) in Figure 0(d). Throughout training on this long task sequence, the network capacity of HAT is rapidly exhausted at an early stage. For the HAT variants that allow parameters allocated to previous tasks to be updated (HAT-random, HAT-const-alpha, and HAT-const-1), the capacity eventually stabilizes at values of 0.50.5 (the mean value of rand(0,1)rand(0,1)), 10−610^-6 (the value to which we set α), and 11, respectively. AdaHAT behaves very similarly to HAT in the early stage. However, whereas HAT eventually exhausts its network capacity, AdaHAT adaptively manages capacity usage over time through its adaptive adjustment rates, causing NC to approach zero without ever reaching it, always preserving some network capacity for learning future tasks. This is the key mechanism by which AdaHAT balances the stability-plasticity trade-off when maintaining stability begins to compromise plasticity, thereby alleviating the network capacity problem in HAT. (e) Evolution of A over the task sequence for AdaHAT and its ablated approaches on 50 tasks, Permuted MNIST. (f) Evolution of A over the task sequence for AdaHAT with different choices of the hyperparameter α. 4.3 Ablation Study To provide insights into the individual effects of the two pieces of information incorporated into the adjustment rate of AdaHAT, we design and compare the following ablated variants to analyze how each of them helps improve HAT by fixing the other information as a constant value: • AdaHAT-no-sum: To study the effect of parameter importance, we fix all the summative attention min(ml,i<t,sum,ml−1,j<t,sum) (m^<t,sum_l,i,m^<t,sum_l-1,j ) at a constant value t, so the adjustment rate solely depends on the network sparsity. Note that we use t instead of 11 because we want to keep the same increasing magnitude as the summative attention. In other words, AdaHAT-no-sum always treats all previous tasks with the same high level of importance. • AdaHAT-no-reg: To study the effect of network sparsity, we fix the regularization term R(Mt,M<t)R ( M^t, M^<t ) at a constant value 0, so the adjustment rate solely depends on the summative attention. In other words, AdaHAT-no-reg always treats the network as if it is under insufficient sparsity. Figure 0(e) shows the results of the ablation study under the same setting as the previous experiments on longer task sequences. Both ablated approaches fail to outperform AdaHAT, suggesting that the guidance from both pieces of information about previous tasks for the adjustment rate is crucial. Moreover, they both outperform HAT in long task sequences, suggesting that the adaptive gradient adjustment mechanism is the key to the improved overall performance of AdaHAT. We observe that AdaHAT-no-reg consistently underperforms AdaHAT. AdaHAT-no-reg uses more aggressive adjustment rates from the beginning, as if network capacity were insufficient, even though it is in fact still sufficient. It thus prematurely sacrifices the stability inherited from HAT before plasticity is actually reduced, leading to significant performance drops on early tasks and making it difficult to catch up with AdaHAT on future tasks. This conversely reflects the effect discussed in Section 3.1 that the network sparsity information helps mitigate the early forgetting of AdaHAT. Similarly, we observe that AdaHAT-no-sum underperforms AdaHAT in much the same way as AdaHAT-no-reg, as it loses another piece of crucial information, leading to less effective and targeted gradient adjustments. An interesting observation here is that AdaHAT-no-sum’s performance declines increasingly slowly and gradually approaches that of AdaHAT as more tasks arrive. The explanation is that, over a long task sequence, the network keeps allocating its parameters to new tasks, so that all parameters tend to have a similar likelihood of having been allocated to a comparable number of previous tasks, thereby making it increasingly difficult to distinguish parameter importance. When the parameter importance scores become less informative and discriminative, the mechanism of AdaHAT effectively reduces to that of AdaHAT-no-sum, so the two behave similarly. 4.4 Hyperparameter Study AdaHAT introduces only one hyperparameter, α, which acts as an additional regulation for the stability-plasticity trade-off by controlling the overall intensity of gradient adjustment. We evaluate α over a range of values 10−7,2×10−7,…,9×10−7,10−6,2×10−6,…,10−510^-7,2× 10^-7,…,9× 10^-7,10^-6,2× 10^-6,…,10^-5 to determine the optimal configuration and analyze its effect. Figure 0(f) shows the results of the hyperparameter study under 20 tasks, Permuted MNIST. We observe that AdaHAT performs the best when α is set to 10−610^-6 in this setting. Increasing α to 10−510^-5 leads to significant performance drops as larger gradient adjustments cause more forgetting. Conversely, smaller value of α is not optimal either. For example, while α=10−7α=10^-7 performs well in the early tasks, it drops instead after around 15 tasks. Overall, α=10−6α=10^-6 achieves the optimal balance between stability and plasticity. Note that 10−610^-6 is a very small value, indicating that the parameters allocated to previous tasks are restricted to extremely small updates. Since this leaves very limited room for gradient adjustment, designing a proper and well-guided adjustment rate that makes effective use of it becomes both more important and more difficult. 5 Conclusion Catastrophic forgetting is one of the fundamental challenges faced by deep neural networks, which has attracted a lot of research in continual learning. Several existing architecture-based approaches that use hard attention mechanism to prevent the network from forgetting what it has learned in previous tasks tend to tilt the stability-plasticity trade-off towards stability, and suffer from the insufficient network capacity problem in long sequences of tasks. Consequently, these approaches perform well when network capacity is sufficient, yet degrade drastically once it is exhausted when learning long task sequences. In this paper, we propose a novel task-based attention mechanism, Adaptive Hard Attention to the Task (AdaHAT), which is built on HAT and replaces its hard gradient clipping with a soft, adaptive gradient adjustment that allows small and controlled updates to the parameters allocated to previous tasks. AdaHAT can preserve the stability benefits from HAT but also rebalance the stability-plasticity trade-off and alleviate the network capacity problem. Experimental results showed that AdaHAT outperforms HAT and the other baselines especially on long task sequences. The results on stability, plasticity, and network capacity usage indicate that, the adaptive behavior by which AdaHAT manages the network capacity over time, balancing the stability-plasticity trade-off, is closely related to its better performance. Our proposed adaptive parameter updating approach also showed that in the architecture-based approaches, those static parameters allocated to previous tasks can be safely updated at small magnitudes when a long task sequence reaches the capacity limit, provided the updates are well-guided and adaptive. Concretely, both pieces of information about previous tasks we have incorporated into the adjustment rate play a crucial role in guiding these parameter updates, shown in ablation results. Going further, we believe finer-grained task information can be explored and exploited to this end. We leave this to future work. References [1] P. Buzzega, M. Boschini, A. Porrello, D. Abati, and S. Calderara (2020) Dark experience for general continual learning: a strong, simple baseline. In Advances in Neural Information Processing Systems, p. 15920–15930. Cited by: §1, §2. [2] C. Fernando, D. Banarse, C. Blundell, Y. Zwols, D. Ha, A. A. Rusu, A. Pritzel, and D. Wierstra (2017) PathNet: evolution channels gradient descent in super neural networks. arXiv preprint arXiv:1701.08734. Cited by: §1. [3] I. J. Goodfellow, M. Mirza, D. Xiao, A. Courville, and Y. Bengio (2014) An empirical investigation of catastrophic forgetting in gradient-based neural networks. In Proceedings of the International Conference on Learning Representations, Cited by: §1, 1st item. [4] K. He, X. Zhang, S. Ren, and J. Sun (2016) Deep residual learning for image recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, p. 770–778. Cited by: §4.1. [5] S. C. Y. Hung, C. Tu, C. Wu, C. Chen, Y. Chan, and C. Chen (2019) Compacting, picking and growing for unforgetting continual learning. In Advances in Neural Information Processing Systems, p. 13647–13657. Cited by: §2. [6] P. Kaushik, A. Gain, A. Kortylewski, and A. L. Yuille (2021) Understanding catastrophic forgetting and remembering in continual learning with optimal relevance mapping. arXiv preprint arXiv:2102.11343. Cited by: §4.1. [7] D. P. Kingma and J. Ba (2015) Adam: A method for stochastic optimization. In Proceedings of the International Conference on Learning Representations, Cited by: §4.1. [8] J. Kirkpatrick, R. Pascanu, N. Rabinowitz, J. Veness, G. Desjardins, A. A. Rusu, K. Milan, J. Quan, T. Ramalho, A. Grabska-Barwinska, et al. (2017) Overcoming catastrophic forgetting in neural networks. Proceedings of the National Academy of Sciences 114 (13), p. 3521–3526. Cited by: §1, §2, 4th item. [9] M. D. Lange, R. Aljundi, M. Masana, S. Parisot, X. Jia, A. Leonardis, G. G. Slabaugh, and T. Tuytelaars (2022) A continual learning survey: defying forgetting in classification tasks. IEEE Transactions on Pattern Analysis and Machine Intelligence 44 (7), p. 3366–3385. Cited by: §1, §1, §2, §2, §3. [10] S. Lee, J. Kim, J. Jun, J. Ha, and B. Zhang (2017) Overcoming catastrophic forgetting by incremental moment matching. In Advances in Neural Information Processing Systems, p. 4652–4662. Cited by: §1, §2. [11] Z. Li and D. Hoiem (2018) Learning without forgetting. IEEE Transactions on Pattern Analysis and Machine Intelligence 40 (12), p. 2935–2947. Cited by: §1, §2, 3rd item. [12] D. Lopez-Paz and M. Ranzato (2017) Gradient episodic memory for continual learning. In Advances in Neural Information Processing Systems, p. 6467–6476. Cited by: §1, §2. [13] A. Mallya, D. Davis, and S. Lazebnik (2018) Piggyback: adapting a single network to multiple tasks by learning to mask weights. In Proceedings of the European Conference on Computer Vision, p. 72–88. Cited by: §1, §2. [14] A. Mallya and S. Lazebnik (2018) PackNet: adding multiple tasks to a single network by iterative pruning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, p. 7765–7773. Cited by: §1, §2, §2. [15] M. McCloskey and N. J. Cohen (1989) Catastrophic interference in connectionist networks: the sequential learning problem. In Psychology of Learning and Motivation, p. 109–165. Cited by: §1. [16] C. V. Nguyen, Y. Li, T. D. Bui, and R. E. Turner (2018) Variational continual learning. In Proceedings of the International Conference on Learning Representations, Cited by: §1, §2. [17] R. Ratcliff (1990) Connectionist models of recognition memory: constraints imposed by learning and forgetting functions. Psychological Review 97 (2), p. 285. Cited by: §1. [18] A. A. Rusu, N. C. Rabinowitz, G. Desjardins, H. Soyer, J. Kirkpatrick, K. Kavukcuoglu, R. Pascanu, and R. Hadsell (2016) Progressive neural networks. arXiv preprint arXiv:1606.04671. Cited by: §2, §2. [19] J. Serrà, D. Suris, M. Miron, and A. Karatzoglou (2018) Overcoming catastrophic forgetting with hard attention to the task. In Proceedings of the International Conference on Machine Learning, p. 4555–4564. Cited by: item 2, §1, §1, §2, §2, §2, §3.1, §3, 5th item, §4.1, §4.1. [20] H. Shin, J. K. Lee, J. Kim, and J. Kim (2017) Continual learning with deep generative replay. In Advances in Neural Information Processing Systems, p. 2990–2999. Cited by: §1, §2. [21] R. K. Srivastava, J. Masci, S. Kazerounian, F. J. Gomez, and J. Schmidhuber (2013) Compete to compute. In Advances in Neural Information Processing Systems, p. 2310–2318. Cited by: §4.1. [22] G. M. van de Ven and A. S. Tolias (2019) Three scenarios for continual learning. arXiv preprint arXiv:1904.07734. Cited by: §2. [23] L. Wang, X. Zhang, H. Su, and J. Zhu (2024) A comprehensive survey of continual learning: theory, method and application. IEEE Transactions on Pattern Analysis and Machine Intelligence 46 (8), p. 5362–5383. Cited by: §1, §2, §2, §2, §2, §4.1, §4.1. [24] M. Wortsman, V. Ramanujan, R. Liu, A. Kembhavi, M. Rastegari, J. Yosinski, and A. Farhadi (2020) Supermasks in superposition. In Advances in Neural Information Processing Systems, p. 15173–15184. Cited by: §1, §2. [25] F. Zenke, B. Poole, and S. Ganguli (2017) Continual learning through synaptic intelligence. In Proceedings of the International Conference on Machine Learning, p. 3987–3995. Cited by: §1, §2.