Foundations to Frontier
Tests
E. Deep Learning › E19 Continual, Multi-Task and Transfer Learning

Continual Learning: EWC, Replay and Progressive Networks

Continual (lifelong) learning trains a model on a sequence of tasks without losing what it learned earlier. Plain sequential training suffers catastrophic forgetting. There are three main remedies. Regularisation methods like elastic weight consolidation (EWC) penalise changes to parameters that mattered for old tasks. Replay methods rehearse a small memory of old examples. Architectural methods like progressive networks add new capacity for each task. This page covers forgetting, the stability–plasticity dilemma, the Fisher information behind EWC, replay buffers and reservoir sampling, progressive networks and evaluation metrics. In the exercises you implement the EWC penalty, reservoir sampling and a forgetting measure. You then learn three permuted tasks in sequence. Task 1 fell from 0.79 to 0.57 under naive training. EWC kept 0.62 (λ = 1000) or 0.71 (λ = 10,000), but the newest task fell from 0.79 to 0.69. A 50-example replay buffer kept 0.61. Separate columns never forget (0.78).

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Learning new things without forgetting old ones

Train a network on task A, then on task B, and it usually forgets A. Its weights simply move to wherever B needs them. People don’t work this way, and robots that learn on the job shouldn’t either. Continual learning methods protect the weights that mattered for A, rehearse a few saved examples of A, or add fresh capacity for B. The demo shows the trade-off in EWC: a stronger penalty keeps task A’s loss low but makes task B harder to learn.

Transfer and efficiency lab
Parameters after learning task B: (0.80, 0.80). Task A loss 0.32, task B loss 0.68. EWC protects the direction task A cares about (high Fisher) and lets the unimportant one move.
Why engineers care

Deployed systems meet new conditions: a satellite’s sensors age, a robot visits new environments, a fault detector sees new failure modes. Retraining from scratch on all past data is often impossible, so continual learning matters.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Training on B after A usually…
  2. 2. Replay methods…
  3. 3. A stronger EWC penalty…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Catastrophic forgetting: gradient steps for the new task change shared weights that old tasks rely on.
  • EWC (Kirkpatrick et al., 2017): add (λ/2) Σ_i F_i (θ_i − θ*_i)² after each task.
    • θ* are the old optimum’s weights.
    • F_i is the diagonal Fisher information, the mean squared gradient of the log-likelihood.
    • Example: F = 4, δ = 0.5, λ = 2 gives 1.
    • It is a Laplace approximation of the old task’s posterior.
  • Replay: keep a buffer (for example 50 examples per old task) and mix it into every batch. Reservoir sampling keeps each of n streamed items with probability capacity/n without knowing n in advance.
  • Progressive networks: freeze old columns and add a new column per task with lateral connections from earlier columns. There is no forgetting by construction, but parameters grow with the number of tasks, and the task identity is needed at test time.
  • Metrics: average final accuracy; backward transfer BWT = mean (final − right-after-learning), which is negative under forgetting; forward transfer.
📝 Quick check (Level 1)
0/3 answered
  1. 1. EWC penalty for F = 4, δ = 0.5, λ = 2:
  2. 2. Reservoir probability for 100 slots after 1000 items:
  3. 3. Progressive networks forget…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Continual learning in code

Exercise 1.

  • Implement the EWC penalty.
  • Implement reservoir sampling and check it keeps a uniform sample of the stream.
  • Measure average forgetting.

Practice.

  • Libraries: Avalanche (PyTorch) implements EWC, replay, GEM, LwF and the benchmarks; Mammoth and Sequoia are research suites.
  • Compute the Fisher on a few hundred samples after each task. Online EWC keeps a running average instead of one penalty per task.
  • Replay with even a tiny buffer is a strong baseline; always include it.
  • Report accuracy on all tasks after each task, not just the final average.
from avalanche.training import EWC, Replay
from avalanche.benchmarks.classic import PermutedMNIST
bench = PermutedMNIST(n_experiences=3)
strategy = EWC(model, optimizer, criterion, ewc_lambda=1000, train_epochs=1)
for exp in bench.train_stream:
    strategy.train(exp); strategy.eval(bench.test_stream)
🐍 Exercise 1: EWC, reservoir sampling and forgetting
Implement the EWC penalty, a reservoir buffer update and average forgetting.
📝 Quick check (Level 2)
0/3 answered
  1. 1. A standard continual-learning library:
  2. 2. Online EWC keeps…
  3. 3. Always report…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

EWC as Bayesian updating. After task A, the posterior p(θ | A) is approximated by a Gaussian centred at θ*_A with precision given by the Fisher. Learning B with log p(B | θ) + log p(θ | A) gives exactly the EWC objective. Parameters with high Fisher are tightly constrained; low-Fisher ones are free.

Stability–plasticity dilemma. Any fixed-capacity learner must trade keeping old knowledge (stability) against acquiring new knowledge (plasticity). In EWC, λ sets this balance directly. Replay sidesteps it partly by approximating joint training, at the cost of memory and privacy.

Scenarios. In task-incremental learning the task identity is known at test time, which is the easiest setting and the one used here (one head per task). In domain-incremental learning it is unknown but the label space is shared. In class-incremental learning new classes arrive over time, which is the hardest setting, where regularisation alone often fails and replay is usually needed.

📝 Quick check (Level 3)
0/3 answered
  1. 1. EWC approximates the old posterior by…
  2. 2. λ in EWC controls…
  3. 3. The hardest scenario:

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How do regularisation, replay and new capacity trade off against forgetting?

History.

  • M. McCloskey and N. J. Cohen, “Catastrophic interference in connectionist networks” (1989).
  • J. Kirkpatrick et al., “Overcoming catastrophic forgetting in neural networks” (PNAS 2017).
  • A. A. Rusu et al., “Progressive neural networks” (2016).
  • D. Rolnick et al., “Experience replay for continual learning” (NeurIPS 2019).

Exercise 2.

  • Tasks: 3 permuted tasks. One labelling rule (3 classes from tanh features of x ∈ ℝ²⁰) is applied to differently permuted inputs. 300 examples per task; tested on 2000.
  • Network: a 20 → 32 → 32 ReLU body with one head per task (task-incremental), trained 200 Adam steps per task.
  • Methods:
    • naive sequential training;
    • EWC (diagonal Fisher from 200 samples) with λ = 100, 1000 or 10,000;
    • replay of 50 stored examples per old task;
    • separate columns (progressive networks without lateral links);
    • joint training on all tasks.
  • Reference: task 1’s accuracy right after learning it was 0.788.
method task 1 task 2 task 3 mean
naive 0.569 0.627 0.792 0.663
EWC, λ = 100 0.581 0.630 0.791 0.667
EWC, λ = 1000 0.620 0.712 0.766 0.699
EWC, λ = 10,000 0.712 0.763 0.688 0.721
replay (50 per task) 0.611 0.677 0.785 0.691
separate columns 0.783 0.758 0.787 0.776
joint training 0.740 0.743 0.780 0.754
  • Forgetting is large: naive training dropped task 1 from 0.788 to 0.569.
  • EWC shows the stability–plasticity trade-off directly: raising λ keeps more of task 1 (0.58 → 0.62 → 0.71) but the newest task falls (0.79 → 0.77 → 0.69).
  • A tiny replay buffer helps without hurting the new task: task 1 0.611, task 3 0.785.
  • Separate columns never forget, because nothing is shared, but they use 3× the parameters, need the task identity, and get no benefit from shared learning.
  • Seeds: seeds 1 and 2 gave naive task 1 0.536/0.615, EWC λ = 10,000 0.70/0.754, replay 0.649/0.686, columns mean 0.783/0.773.
🐍 Exercise 2 (research): how do regularisation, replay and new capacity trade off against forgetting?
Learn three permuted tasks in sequence with naive training, EWC at three strengths, replay, separate columns and joint training; compare per-task accuracy.

Continual learning in AI, robotics and aerospace

  • Robots learning on the job: adding skills or adapting to new environments without forgetting old ones.
  • Spacecraft anomaly detection: updating models as hardware ages and new failure modes appear, without full retraining on the ground.
  • Personalised devices: on-device adaptation with limited memory.
  • Design lesson: start with replay; add regularisation and tune λ against the new task’s accuracy, not only old tasks’.

References

  1. M. McCloskey and N. J. Cohen (1989). “Catastrophic interference in connectionist networks.” Psychology of Learning and Motivation 24.
  2. J. Kirkpatrick et al. (2017). “Overcoming catastrophic forgetting in neural networks.” PNAS 114.
  3. A. A. Rusu et al. (2016). “Progressive neural networks.” arXiv:1606.04671.
  4. G. M. van de Ven and A. S. Tolias (2019). “Three scenarios for continual learning.” arXiv:1904.07734.