Simple Algorithm
Deep Learning · Emergence · 28 min

Catastrophic Forgetting & Continual Learning

Why new training erases old skills, loss of plasticity, and what regularization and replay do about it.

Train a network on task A, then on task B, and its skill at A can vanish within a few hundred updates, while a person who learns a second language does not forget the first. This lesson asks why gradient descent forgets, measures forgetting properly, derives elastic weight consolidation from a Bayesian argument, compares regularization with replay and with growing the network, and then turns to the opposite failure: networks trained for long enough on changing tasks gradually lose the ability to learn at all.

What you’ll learn

  • Explain why sequential gradient training overwrites earlier tasks, and distinguish task-, domain- and class-incremental learning.
  • Derive the elastic weight consolidation penalty from a Laplace approximation of the old task's posterior, and compute it.
  • Compare regularization (EWC, synaptic intelligence, learning without forgetting), replay (experience, generative, gradient episodic memory) and architectural isolation.
  • Describe loss of plasticity, its correlates, and continual backpropagation.
  • Explain forgetting in fine-tuned and continually pretrained large models and the remedies used in practice.

Why networks forget

McCloskey & Cohen (1989) trained a small network on the "ones" addition facts (sums with a 1, such as 1+31+3 and 6+16+1) and then on the "twos". After only a few rounds on the twos, it had largely lost the ones. They called it catastrophic interference; Ratcliff (1990) found the same in models of recognition memory, and French (1999) reviewed what is now usually called catastrophic forgetting.

The mechanism is plain gradient descent. Knowledge in a network is distributed: every weight takes part in many input–output mappings. While training on task B, the gradient ∇LB\nabla\loss_B carries no information about LA\loss_A, so nothing stops the weights from moving in directions that raise LA\loss_A. A system must stay plastic enough to learn and stable enough to remember; this stability–plasticity dilemma is a theme from Stephen Grossberg's work on neural learning, and continual learning studies it for deep networks.

Scenario (van de Ven, Tuytelaars & Tolias, 2022)At test timeExample on split MNIST (digit pairs 0/1, 2/3, …)
Task-incrementalthe task identity is given"Is it the first or second digit of task 3?" with a separate output head per task
Domain-incrementalsame output space, task not given"Is it even or odd?", whichever pair it came from
Class-incrementalmust choose among all classes seen so far"Which of the ten digits is it?"
The scenarios differ sharply in difficulty. Class-incremental learning is the hardest: the network never trained to tell a 1 from a 7 if they appeared in different tasks.

To measure forgetting, record the accuracy matrix Rj,iR_{j,i}, the test accuracy on task ii after training on task jj, for tasks 1,…,T1,\dots,T. Lopez-Paz & Ranzato (2017) summarize it with the final average accuracy and the backward transfer:

ACC=1T∑i=1TRT,i,BWT=1T−1∑i=1T−1(RT,i−Ri,i)\text{ACC}=\frac1T\sum_{i=1}^TR_{T,i},\qquad\text{BWT}=\frac1{T-1}\sum_{i=1}^{T-1}\big(R_{T,i}-R_{i,i}\big)
Negative backward transfer is forgetting. If task 1 dropped from 0.95 to 0.60 and task 2 from 0.94 to 0.80 by the end of three tasks, BWT=((0.60−0.95)+(0.80−0.94))/2≈−0.25\text{BWT}=\big((0.60-0.95)+(0.80-0.94)\big)/2\approx-0.25.

Elastic weight consolidation

Kirkpatrick et al. (2017) asked which weights matter for task A and made those stiff. Their elastic weight consolidation (EWC) follows from Bayes' rule.

DerivationFrom the posterior to a quadratic penalty
  1. log⁡p(θ∣DA,DB)=log⁡p(DB∣θ)+log⁡p(θ∣DA)−log⁡p(DB∣DA)\log p(\boldsymbol\theta\mid\data_A,\data_B)=\log p(\data_B\mid\boldsymbol\theta)+\log p(\boldsymbol\theta\mid\data_A)-\log p(\data_B\mid\data_A)

    Treat the data of the two tasks as conditionally independent given the weights. The posterior after both tasks is then the likelihood of B times the posterior after A, which already contains everything learned from A:

  2. log⁡p(θ∣DA)≈const−12(θ−θA⋆)⊤HA (θ−θA⋆),HA=−∇2log⁡p(θ∣DA)∣θA⋆\log p(\boldsymbol\theta\mid\data_A)\approx\text{const}-\tfrac12(\boldsymbol\theta-\boldsymbol\theta^\star_A)^\top H_A\,(\boldsymbol\theta-\boldsymbol\theta^\star_A),\qquad H_A=-\nabla^2\log p(\boldsymbol\theta\mid\data_A)\big|_{\boldsymbol\theta^\star_A}

    The old posterior is intractable, so make a Laplace approximation: expand its logarithm to second order around the weights θA⋆\boldsymbol\theta^\star_A found on task A, which approximately maximize it, so the linear term vanishes:

  3. HA≈FA≈diag⁡(F1,…,FP),Fi=E[(∂log⁡p(y∣x,θ)∂θi)2]H_A\approx F_A\approx\diag(F_1,\dots,F_P),\qquad F_i=\E\Big[\Big(\frac{\partial\log p(y\mid\mathbf x,\boldsymbol\theta)}{\partial\theta_i}\Big)^2\Big]

    Replace the Hessian by the Fisher information F=E[∇log⁡p(y∣x,θ) ∇log⁡p(y∣x,θ)⊤]F=\E\big[\nabla\log p(y\mid\mathbf x,\boldsymbol\theta)\,\nabla\log p(y\mid\mathbf x,\boldsymbol\theta)^\top\big] at θA⋆\boldsymbol\theta^\star_A, which equals the expected Hessian of the negative log-likelihood when yy is drawn from the model, is positive semidefinite and needs only first derivatives. Keep its diagonal FiF_i, one number per weight:

  4. L(θ)=LB(θ)+∑iλ2Fi(θi−θA,i⋆)2\loss(\boldsymbol\theta)=\loss_B(\boldsymbol\theta)+\sum_i\frac\lambda2F_i\big(\theta_i-\theta^\star_{A,i}\big)^2

    Negate the log-posterior to get the loss for task B. Each weight is tied to its old value by a spring of stiffness λFi\lambda F_i, where λ\lambda sets how much task A counts:

Predict before you look

Three weights have Fisher values F=(2.0, 0.5, 0.01)F=(2.0,\ 0.5,\ 0.01). Training on task B moves them by (0.1, 0.3, 1.0)(0.1,\ 0.3,\ 1.0) from their task-A values. With λ=100\lambda=100, what is the EWC penalty?

Show the answer

3.75

1002(2.0×0.01+0.5×0.09+0.01×1.0)=50×0.075=3.75\tfrac{100}2\big(2.0\times0.01+0.5\times0.09+0.01\times1.0\big)=50\times0.075=3.75. The weight that moved most, by 1.01.0, contributes least, because task A barely depends on it: EWC lets unimportant weights move freely and pins the important ones. Plain L2 toward θA⋆\boldsymbol\theta^\star_A would treat all three alike.

EWC protected earlier tasks on permuted-MNIST sequences and on a sequence of Atari games in the original paper. Its approximations are visible in its failures: the diagonal ignores correlations between weights, the quadratic is only accurate near θA⋆\boldsymbol\theta^\star_A, and penalties accumulate as tasks pile up.

Two other regularizers avoid computing a Fisher matrix. Synaptic intelligence (Zenke, Poole & Ganguli, 2017) measures importance online, as each weight's contribution to the drop in loss along the training path of task ν\nu, ωkν=−∑tgk(t) Δθk(t)\omega_k^\nu=-\sum_tg_k(t)\,\Delta\theta_k(t), normalizes it by the weight's total movement Δkν\Delta_k^\nu during that task, Ωk=∑ν<μωkν/((Δkν)2+ξ)\Omega_k=\sum_{\nu<\mu}\omega_k^\nu/\big((\Delta_k^\nu)^2+\xi\big), and while training task μ\mu adds the penalty c∑kΩk(θk−θ~k)2c\sum_k\Omega_k(\theta_k-\tilde\theta_k)^2 around the previous task's end point θ~\tilde{\boldsymbol\theta}. Learning without forgetting (Li & Hoiem, 2017) protects functions rather than weights: before training on the new task it records the old heads' outputs on the new task's images, and then adds a distillation loss that keeps those outputs unchanged, with no old data stored.

Replay and architectural isolation

The bluntest remedy is to keep training on the old tasks. Experience replay stores a small memory of past examples and mixes them into every batch. It is hard to beat: a very simple baseline that trains jointly on the current task and a tiny memory of stored examples outperformed methods designed for continual learning, regularizers included (Chaudhry et al., 2019), and replay combined with behavioral cloning sharply reduced forgetting in reinforcement-learning agents (Rolnick et al., 2019). When storing data is not allowed, generative replay trains a generative model of past inputs and replays samples from it, labeled by the old network (Shin, Lee, Kim & Kim, 2017).

Gradient episodic memory (GEM; Lopez-Paz & Ranzato, 2017) uses the memory as a constraint rather than as training data: an update may not increase the loss on any stored task. To first order, that means the update direction g\mathbf g must have a nonnegative inner product with each task's memory gradient gk\mathbf g_k.

DerivationProjecting the gradient (the one-constraint case)
  1. g⊤gref ≥ 0\mathbf g^\top\mathbf g_{\text{ref}}\ \ge\ 0

    A small step −ηg-\eta\mathbf g changes the memory loss by −η g⊤gref-\eta\,\mathbf g^\top\mathbf g_{\text{ref}} to first order, so it does not increase the memory loss if

  2. g~=g−g⊤grefgref⊤gref gref\tilde{\mathbf g}=\mathbf g-\frac{\mathbf g^\top\mathbf g_{\text{ref}}}{\mathbf g_{\text{ref}}^\top\mathbf g_{\text{ref}}}\,\mathbf g_{\text{ref}}

    If the constraint is violated, replace g\mathbf g by the closest vector that satisfies it. Minimizing ∥g~−g∥2\norm{\tilde{\mathbf g}-\mathbf g}^2 subject to g~⊤gref=0\tilde{\mathbf g}^\top\mathbf g_{\text{ref}}=0 removes the component along gref\mathbf g_{\text{ref}}:

  3. This is A-GEM (Chaudhry et al., 2019), which uses one reference gradient averaged over the whole memory. The original GEM keeps one constraint per past task and solves a small quadratic program in the dual, with as many variables as tasks.

Architectural isolation gives each task its own parameters. Progressive networks (Rusu et al., 2016) add a new column of layers per task, with lateral connections from the frozen earlier columns: no forgetting at all, but the network grows with every task. PackNet (Mallya & Lazebnik, 2018) works within a fixed network instead: after each task it prunes the least important weights, freezes the survivors, and frees the pruned ones for the next task, storing one binary mask per task. Both need the task identity at test time, so they fit the task-incremental setting.

Check your understanding

On class-incremental split MNIST (pairs of digits arrive one after another, and the final model must name any of the ten digits), van de Ven & Tolias (2019) found that EWC and synaptic intelligence failed while replay worked. Why?

  1. The Fisher information cannot be computed for classification networks
  2. The regularizers protect weights that were important for each old task, but nothing ever trained the network to tell digits of different tasks apart; replay puts old and new classes in the same batches
  3. The penalties were too strong, so the network could not learn new digits
  4. Replay uses more parameters than regularization
Show the answer

B. The regularizers protect weights that were important for each old task, but nothing ever trained the network to tell digits of different tasks apart; replay puts old and new classes in the same batches

In class-incremental learning the output for "1" and the output for "7" must compete, yet if they were trained in different tasks they were never compared. Keeping old weights in place does not create that comparison; training on stored or generated examples of old classes alongside new ones does.

Loss of plasticity

Forgetting is the old knowledge leaving. Loss of plasticity is the opposite failure: the ability to learn new things leaving. Dohare, Hernandez-Garcia, Lan, Rahman, Mahmood & Sutton (2024) trained networks on long task sequences: thousands of binary classification tasks built from pairs of ImageNet classes, class-incremental CIFAR-100, hundreds of permuted versions of MNIST, and reinforcement learning on a simulated ant robot whose friction changes. Standard deep learning gradually lost plasticity until it learned new tasks no better than a shallow (linear) network. The loss came with three measurable changes: steadily growing weight magnitudes, more and more dead units, and a falling effective rank of the representation.

Among existing remedies, L2 regularization and shrink and perturb (shrink the weights toward zero and add small noise) helped most, but were sensitive to their settings; dropout and standard Adam made things worse. Their proposal, continual backpropagation, keeps injecting diversity. Every unit gets a utility, a running average of the magnitude of its activation times the total magnitude of its outgoing weights; a tiny fraction of the lowest-utility mature units (for example 10−510^{-5} per step) is reinitialized, with input weights redrawn from the initial distribution and outgoing weights set to zero, so the network's current function is unchanged at the moment of reset. With it, plasticity was maintained throughout their experiments.

Forgetting in large pretrained models

Every fine-tuning run is a two-task sequence, pretraining then the target, so foundation models forget too: robustness to distribution shift, abilities outside the fine-tuning data, even behaviors instilled by earlier post-training. Several remedies above reappear at scale:

  • Keep the features in place. Fitting the head before fine-tuning (LP-FT) distorts pretrained features less and preserved out-of-distribution accuracy (Kumar et al., 2022). Interpolating the weights of the zero-shot and the fine-tuned model is another route (Model Merging & Task Arithmetic).
  • Restrict the update. LoRA forgets less than full fine-tuning, and its forgetting concentrates in a few new singular directions (Low-Rank Adaptation in Depth); L2-SP pulls toward the pretrained weights, a crude EWC with Fi=1F_i=1.
  • Replay. Mixing a fraction of earlier data into later training remains the most dependable defense.

Continual pretraining of language models shows the trade-off at its largest. A run that ended with a decayed learning rate must raise it again to learn new data efficiently, and re-warming itself causes forgetting. Ibrahim et al. (2024) found that the combination of learning-rate re-warming, re-decaying and replay of a fraction of the old data matched retraining from scratch on all the data, for a weak shift (English to English) and a strong one (English to German) with 405-million-parameter models, and for the weak shift also with a 10-billion-parameter model, at a fraction of the compute; they also proposed schedules that avoid the re-warming step.

Key takeaways

  • Sequential gradient training forgets because the gradient of a new task ignores the old ones; class-incremental learning, with no task identity at test time, is the hardest scenario, and backward transfer measures the damage.
  • EWC follows from a Laplace approximation of the old task's posterior with a diagonal Fisher: LB(θ)+∑iλ2Fi(θi−θA,i⋆)2\loss_B(\boldsymbol\theta)+\sum_i\tfrac\lambda2F_i(\theta_i-\theta^\star_{A,i})^2, which pins important weights and frees the rest; synaptic intelligence estimates importance online, and learning without forgetting distills the old outputs.
  • Replay, even from a tiny memory, is the most dependable remedy; GEM and A-GEM turn the memory into constraints on the gradient, and progressive networks and PackNet isolate parameters per task.
  • Long continual training also destroys plasticity: weights grow, units die and effective rank falls until a deep network learns no better than a linear one; continual backpropagation's selective reinitialization prevents it in the reported experiments.
  • Large models forget during fine-tuning and continual pretraining; LP-FT, low-rank updates, weight interpolation, and learning-rate re-warming and re-decaying combined with replay are the practical defenses.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Under elastic weight consolidation, which weights are held most firmly near their task-A values while training on task B?

  1. The weights with the largest values
  2. The weights that changed most during task A
  3. The weights with the largest diagonal Fisher information for task A, i.e. those the old task's likelihood is most sensitive to
  4. All weights equally, as in L2 regularization
Show the answer

C. The weights with the largest diagonal Fisher information for task A, i.e. those the old task's likelihood is most sensitive to

The penalty λ2∑iFi(θi−θA,i⋆)2\tfrac\lambda2\sum_iF_i(\theta_i-\theta^\star_{A,i})^2 is a spring of stiffness λFi\lambda F_i on each weight. FiF_i approximates the curvature of the old task's log-posterior, so moving a high-Fisher weight costs task A the most.

Question 2

After three tasks, a method's accuracy on task 1 fell from 0.920.92 (just after learning it) to 0.800.80, and on task 2 from 0.900.90 to 0.860.86. What is its backward transfer?

  1. −0.08-0.08
  2. −0.16-0.16
  3. +0.08+0.08
  4. −0.04-0.04
Show the answer

A. −0.08-0.08

BWT=12[(0.80−0.92)+(0.86−0.90)]=12(−0.12−0.04)=−0.08\text{BWT}=\frac12\big[(0.80-0.92)+(0.86-0.90)\big]=\frac12(-0.12-0.04)=-0.08. Negative backward transfer measures forgetting; positive values would mean later tasks improved earlier ones.

Question 3

In A-GEM, the proposed gradient g\mathbf g has a negative inner product with the memory's reference gradient gref\mathbf g_{\text{ref}}. What does the method do?

  1. Skips the update entirely
  2. Adds gref\mathbf g_{\text{ref}} to g\mathbf g
  3. Doubles the learning rate to escape the conflict
  4. Removes from g\mathbf g its component along gref\mathbf g_{\text{ref}}, the closest change that no longer increases the memory loss to first order
Show the answer

D. Removes from g\mathbf g its component along gref\mathbf g_{\text{ref}}, the closest change that no longer increases the memory loss to first order

g~=g−g⊤gref∥gref∥2gref\tilde{\mathbf g}=\mathbf g-\frac{\mathbf g^\top\mathbf g_{\text{ref}}}{\norm{\mathbf g_{\text{ref}}}^2}\mathbf g_{\text{ref}} is the projection onto the half-space g~⊤gref≥0\tilde{\mathbf g}^\top\mathbf g_{\text{ref}}\ge0. When there is no conflict, g\mathbf g is used unchanged.

Question 4

What does continual backpropagation do to keep a network able to learn new tasks?

  1. It freezes the weights important for old tasks
  2. It periodically reinitializes a tiny fraction of low-utility units, redrawing their input weights and zeroing their outgoing weights
  3. It replays stored examples of all old tasks
  4. It retrains the network from scratch after every task
Show the answer

B. It periodically reinitializes a tiny fraction of low-utility units, redrawing their input weights and zeroing their outgoing weights

Units whose activations and outgoing weights contribute little are replaced with fresh ones, injecting the diversity that a random initialization provides. Zeroing the outgoing weights leaves the current function unchanged at the moment of the reset.

Further reading

  • M. McCloskey & N. J. Cohen, "Catastrophic interference in connectionist networks: the sequential learning problem," Psychology of Learning and Motivation 24 (1989).
  • J. Kirkpatrick et al., "Overcoming catastrophic forgetting in neural networks," PNAS 114(13) (2017).
  • D. Lopez-Paz & M. Ranzato, "Gradient episodic memory for continual learning," NeurIPS (2017).
  • G. M. van de Ven, T. Tuytelaars & A. S. Tolias, "Three types of incremental learning," Nature Machine Intelligence 4 (2022).
  • S. Dohare, J. F. Hernandez-Garcia, Q. Lan, P. Rahman, A. R. Mahmood & R. S. Sutton, "Loss of plasticity in deep continual learning," Nature 632 (2024).