AnyLearn
All lessons
AIintermediate

Catastrophic Forgetting: Why Neural Networks Overwrite What They Knew

Train a network on one task, then another, and the first often collapses. This lesson shows why: shared weights and conflicting gradients, demonstrated in twenty lines of code, then the stability-plasticity dilemma, the less known loss of plasticity, and how the brain's replay suggests the fixes.

Updated · AI-authored, review-gated · how lessons are made

Progress1 / 10

Learning in sequence breaks a hidden assumption

Standard training shuffles one fixed dataset, so every minibatch is a fair sample of everything the model must know. That assumption, that examples are independent and identically distributed, quietly hides a problem. It appears the moment data arrives in order: a new task, a new domain, new classes, this month's documents.

Train a network on task A, then train it only on task B, and its accuracy on A often collapses. Not gradually, and not because B was hard: within a few hundred updates the weights that encoded A have been repurposed. This is catastrophic forgetting, also called catastrophic interference.

Definition: Continual learning is training one model on a sequence of tasks or a non-stationary data stream so that it acquires new knowledge without losing the old, usually without unlimited access to earlier data.

The last clause matters. If you could keep every old example and retrain from scratch each time, there would be no scientific problem, only a compute bill. Continual learning exists because storage, compute, privacy or licensing make full retraining impractical.

Sign in free to save your progress and earn certificates.

Full lesson text

All 10 steps on one page, for reading, reference, and search.

Show

1. Learning in sequence breaks a hidden assumption

Standard training shuffles one fixed dataset, so every minibatch is a fair sample of everything the model must know. That assumption, that examples are independent and identically distributed, quietly hides a problem. It appears the moment data arrives in order: a new task, a new domain, new classes, this month's documents.

Train a network on task A, then train it only on task B, and its accuracy on A often collapses. Not gradually, and not because B was hard: within a few hundred updates the weights that encoded A have been repurposed. This is catastrophic forgetting, also called catastrophic interference.

Definition: Continual learning is training one model on a sequence of tasks or a non-stationary data stream so that it acquires new knowledge without losing the old, usually without unlimited access to earlier data.

The last clause matters. If you could keep every old example and retrain from scratch each time, there would be no scientific problem, only a compute bill. Continual learning exists because storage, compute, privacy or licensing make full retraining impractical.

2. A problem named in 1989

McCloskey and Cohen (1989) trained a backpropagation network on the 'ones' addition facts, then on the 'twos'. Its answers on the ones collapsed after only a few passes over the twos, and changing the number of hidden units or the learning rate did not cure it. Hetherington and Seidenberg (1989) then showed that interleaving old items with new ones greatly reduces the damage, which is the seed of every replay method.

timeline
  title Catastrophic forgetting, key papers
  1987 : Carpenter and Grossberg frame the stability-plasticity dilemma in adaptive resonance theory
  1989 : McCloskey and Cohen name catastrophic interference
  1990 : Ratcliff shows it in models of recognition memory
  1995 : McClelland, McNaughton and O'Reilly propose complementary learning systems
  1999 : French reviews causes and remedies in Trends in Cognitive Sciences
  2017 : Kirkpatrick et al. introduce elastic weight consolidation
  2022 : van de Ven, Tuytelaars and Tolias define three incremental scenarios

3. Why it happens: one set of weights, two objectives

Every weight in a network takes part in many computations. That is what makes distributed representations powerful, and it is what makes them fragile. Training on B minimises B's loss and is blind to A's, because A's data is not in the batch. A first-order expansion shows what one gradient step on B, with learning rate η\eta, does to A's loss:

ΔLA≈−η ∇LA(θ)⊤∇LB(θ)\Delta L_A \approx -\eta \, \nabla L_A(\theta)^\top \nabla L_B(\theta)

If the two gradients point the same way (positive dot product), learning B also improves A. If they are orthogonal, A is roughly untouched. If they conflict, every step on B climbs A's loss, and nothing in B's objective notices.

Key idea: Forgetting is interference, not a capacity limit. A network large enough to learn A and B jointly can still forget A when they arrive in sequence, because the sequential path never visits the joint solution. The optimiser simply reuses whichever weights reduce B's loss fastest, and those are often the ones A depended on.

4. Forgetting in twenty lines

Linear regression is the smallest model that shows the mechanism. Each task draws inputs from a subspace and targets from its own random linear rule; one weight vector serves both. Train on A, then on B only, and measure A again.

import numpy as np

rng = np.random.default_rng(0)
d, n = 20, 200

def make_task(basis):
    # inputs live in the subspace spanned by `basis`; targets from a random linear rule
    X = rng.normal(size=(n, basis.shape[0])) @ basis
    w_true = rng.normal(size=d)
    return X, X @ w_true

def mse(w, X, y):
    return np.mean((X @ w - y) ** 2)

def train(w, X, y, lr=0.01, steps=2000):
    for _ in range(steps):
        w = w - lr * 2 * X.T @ (X @ w - y) / len(y)
    return w

I = np.eye(d)
for name, basis_A, basis_B in [
    ("shared inputs  ", I, I),               # both tasks use all 20 features
    ("disjoint inputs", I[:10], I[10:]),     # A uses features 0-9, B uses 10-19
]:
    XA, yA = make_task(basis_A)
    XB, yB = make_task(basis_B)
    w = train(np.zeros(d), XA, yA)
    before = mse(w, XA, yA)
    w = train(w, XB, yB)                    # now learn task B only
    print(f"{name}: task A loss {before:.4f} -> {mse(w, XA, yA):.2f} after B "
          f"(task B loss {mse(w, XB, yB):.4f}; predicting 0 on A: {np.mean(yA**2):.2f})")

Output:

shared inputs  : task A loss 0.0000 -> 30.90 after B (task B loss 0.0000; predicting 0 on A: 15.39)
disjoint inputs: task A loss 0.0000 -> 0.00 after B (task B loss 0.0000; predicting 0 on A: 12.35)

With shared inputs, learning B drives A's error from zero to 30.90, twice as bad as always answering zero. With inputs in disjoint subspaces, B's gradient never touches the weights A relies on, and A survives untouched. Forgetting scales with how much two tasks compete for the same parameters.

5. Overlap is not the same as conflict

The demo used disjoint inputs to make gradients orthogonal, but what matters is the direction of the gradients in weight space, not whether the inputs look alike.

Relationship of the gradients on shared weightsEffect of training on BTypical situation
Aligned (positive dot product)A improves: positive backward transferB is a closely related variant of A
OrthogonalA roughly unchangedTasks use separate features or units
Opposed (negative dot product)A degrades: forgettingSame inputs, different required outputs
Predict first

Task B uses exactly the same inputs and exactly the same rule as task A, and the network has already mastered A. What happens to A while you train on B?

This is why Gradient Episodic Memory, covered in the next lesson, checks the sign of exactly this dot product before every update.

6. The stability-plasticity dilemma

Every continual learner sits on a dial. Turn it toward stability and old knowledge is protected, but new tasks are learned slowly or not at all. Turn it toward plasticity and new tasks are learned quickly, at the expense of the old. Grossberg's adaptive resonance theory made this the central design question, and it still organises the field: the survey by Wang, Zhang, Su and Zhu (IEEE TPAMI) states the goal of continual learning as a proper stability-plasticity trade-off plus adequate generalisation, within resource limits.

Too stableToo plastic
SymptomNew tasks plateau at low accuracyOld tasks collapse
Name in the literatureIntransigenceForgetting
Extreme caseA frozen networkPlain sequential fine-tuning

The term intransigence comes from Chaudhry et al. (2018), who proposed measuring it alongside forgetting.

Gotcha: A frozen network has zero forgetting. Any report that shows only how well old tasks were retained, without accuracy on the newest task, can make a useless method look perfect.

7. The other failure: losing the ability to learn

Plasticity is not guaranteed either. Dohare, Sutton and colleagues at the University of Alberta trained networks on long sequences of tasks built from ImageNet and MNIST (their study, Loss of plasticity in deep continual learning, appeared in Nature in 2024). In their preprint, binary classification accuracy on ImageNet fell from 89% on an early task to 77% by the 2,000th task, roughly the level of a linear network. The network still had all its parameters; it had lost the capacity to use them.

What they observed accompanying the decline:

  • Dead units. ReLU units that never activate receive no gradient; with one step size, up to 25% of units died after 800 tasks of permuted MNIST.
  • Growing weights. Weight magnitudes drift upward, making the network harder to move.
  • Collapsing effective rank. Hidden representations become lower-dimensional, so fewer distinct features are available for a new task.

L2 regularisation, especially combined with small weight perturbations, eased the problem. Their continual backpropagation algorithm reinitialises a small fraction of rarely used units as training goes, and appeared to keep plasticity indefinitely.

In practice: For a long-running learner, monitor both sides: retained accuracy on old data and how fast a fresh task is learned.

8. How the brain seems to sidestep it

McClelland, McNaughton and O'Reilly (1995) argued that the brain has two learning systems precisely because of catastrophic interference. The hippocampus learns a single episode fast, with sparse codes that overlap little. The neocortex learns slowly, and old memories are replayed to it, interleaved with new experience, so its overlapping representations absorb new structure without being overwritten. The neuroscience cursus lesson on synapses and plasticity covers the synaptic machinery itself; here the point is architectural.

flowchart LR
  E["New experience"] --> H["Hippocampus: fast, sparse, low-overlap codes"]
  H --> R["Replay during sleep and rest"]
  R --> N["Neocortex: slow, interleaved, overlapping codes"]
  E --> N
  N --> K["Consolidated knowledge"]

9. What makes forgetting worse or milder

The degree of forgetting is not a fixed property of a network. It moves with choices you control:

  1. How much the tasks conflict. Opposed gradients on shared weights are the direct cause, as the demo showed.
  2. How far training moves the weights. More steps and larger learning rates on the new task travel further from the old solution. For language models, Ibrahim et al. (2024) found that re-warming the learning rate for continued pretraining increases forgetting, a point the final lesson of this cursus returns to.
  3. How much representations overlap. French (1999) traced interference to overlapping hidden representations and reviewed methods that make codes sparser.
  4. Regularisation during training. Goodfellow et al. (2013) found that training with dropout was consistently the best choice among the setups they compared for limiting forgetting.
  5. Whether old outputs must compete with new ones. A shared output layer that must choose among all classes ever seen is much harder to protect than a separate head per task, which is the subject of the evaluation lesson.

Gotcha: Data order alone can create the problem. A curriculum that groups data by source or date is a continual learning setup, even if nobody called it one.

10. Three ways out

The mechanism suggests the remedies directly. If forgetting happens because A's gradient is absent while training B, and because A and B fight over the same weights, there are three levers:

FamilyWhat it doesPrice
Replay (rehearsal)Puts old examples, or generated stand-ins, back into the batchMemory, privacy, extra compute
RegularisationPenalises moving the weights, or outputs, that mattered for old tasksMust estimate importance; weakens with many tasks
Parameter isolationGives each task its own weights, masks or adaptersGrowth in parameters; often needs to know the task at test time

This three-way split follows the taxonomy of the continual learning survey by De Lange et al. (IEEE TPAMI, 2021). The brain's answer, from the previous step, is mostly the first: replay. The next lesson takes each family apart, with the equations and a working comparison in PyTorch.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. According to the first-order view, when does training on task B make a network forget task A?
    • Whenever B has more training examples than A
    • When the gradients of A's and B's losses on the shared weights point in opposing directions
    • Only when the network is too small to represent both tasks
    • Whenever B's inputs come from a different distribution than A's
  2. In the linear regression demo, why did task A survive training on task B when inputs were in disjoint subspaces?
    • The learning rate was too small for B to change anything
    • Task B had a smaller loss to begin with
    • Linear models cannot forget
    • B's gradient only touched weights for features A never used
  3. A paper reports that its method has zero forgetting on all old tasks. What should you check before believing it is useful?
    • Its accuracy on the newest task, since a frozen network also has zero forgetting
    • Whether it used dropout
    • Whether the tasks were presented in a random order
    • The number of hidden units
  4. What did Dohare and colleagues mean by loss of plasticity?
    • Networks forget old tasks faster as they grow
    • Networks stop fitting their training data because of overfitting
    • After many tasks, networks learn new tasks worse, with dead units and collapsing representation rank
    • Networks trained with replay cannot learn new classes
  5. In the complementary learning systems account, how does the neocortex avoid being overwritten by new memories?
    • It stores each memory in a separate set of neurons that is never reused
    • It learns slowly, with old memories replayed and interleaved with new experience
    • It freezes its synapses after childhood
    • It forwards all new memories permanently to the hippocampus

Related lessons

AI
advanced

Fixing Forgetting: Replay, Regularisation, and Parameter Isolation

The three families of continual learning methods, taken apart: experience and generative replay, gradient projection with GEM, weight penalties from EWC and synaptic intelligence, distillation, and per-task adapters. Includes a runnable PyTorch comparison of EWC and replay, and a table for choosing among them.

9 steps·~14 min
AI
advanced

Continual Learning in Large Language Models: Continued Pretraining, Drift, and Editing

Every stage of a language model's life trains the same weights on new data, so every stage can erase the last. Learn the continued-pretraining recipe of re-warming, re-decaying and replay, how fine-tuning erodes skills and safety, why LoRA and on-policy RL forget less, and when editing or retrieval beats training.

10 steps·~15 min
AI
advanced

Measuring Continual Learning: Scenarios, Transfer Metrics, and Honest Baselines

The same method can score 99% or 21% on one benchmark depending on what the model is told at test time. Learn the task-, domain- and class-incremental scenarios, the accuracy matrix with backward and forward transfer, and the protocol choices and baselines that make a continual learning result trustworthy.

9 steps·~14 min
Science
intermediate

Predicted, Made, Proven: Judging a Materials Discovery Claim

How to tell a predicted crystal from a validated new material. Builds an evidence ladder from predicted stable to useful, explains why zero-kelvin calculations invent atomic order that real samples lack, and applies the ladder to three documented cases: a large prediction database, an autonomous lab, and a generative model.

10 steps·~15 min