Skip to content

Continual learning: training on new rows without forgetting

Keep training a network as new rows arrive without erasing what it learned. Replay old rows, anchor the weights with EWC or L2-SP, and measure old and new performance together.

Advanced ~14 min10 steps

What runs in CodeSplash

You will be able to

  • Explain catastrophic forgetting and the stability–plasticity trade-off
  • Write the replay-mixed loss and the EWC penalty
  • Continue training a CodeSplash network with replay rows and an anchor
  • Measure forgetting on the old data next to gains on the new

Read first

01

Forgetting is the default

Read

Train a network further on new rows only, and gradient descent moves every weight toward what the new rows need. Nothing in the loss mentions the old rows, so what the network did well on them can vanish: catastrophic forgettingCatastrophic forgettingA network trained further on new data losing what it learned from its old data..

Continual learningContinual learningUpdating a model across a sequence of tasks or shifting data while trying to keep what it already does well. methods trade plasticity (learning the new) against stability (keeping the old). There are two main levers: show the network some old rows again, or penalize moving the weights that mattered.

02

Replay old rows

Read

Experience replay mixes a sample of old rows into training on the new ones:

L=α Lnew+(1−α) Lold.L = \alpha\, L_{\text{new}} + (1 - \alpha)\, L_{\text{old}} .

In the reference's example, with α set to seven tenths, the mixed loss is 0.425. Replay is simple and strong. Its cost is that you must keep old data: storage, and every privacy duty that comes with those rows.

03

Anchor the important weights

Read

Elastic weight consolidationElastic weight consolidation (EWC)An anchor that pulls each weight back toward its old value, harder for weights that mattered most on the old data. adds a pull back toward the old weights θ∗\theta^*, strongest where the old data cared most:

L=Lnew+λ2∑iFi (θi−θi∗)2.L = L_{\text{new}} + \frac{\lambda}{2} \sum_i F_i\, (\theta_i - \theta^*_i)^2 .

FiF_i is the diagonal of the Fisher information, estimated from gradients on old rows: large where a weight's change would hurt the old fit. In the reference's example, two weights moved by the same amount, but the first has ten times the importance, so it supplies most of the penalty of 0.44. L2-SP is the simpler anchor: every weight pulled back equally.

DExplorable · Forgetting: fine-tuning, EWC and replay

Why does training on a new task erase an old one, and what can hold on to it?

While learning task B

What, if anything, remembers task A during the second phase.

3.0

L2 and EWC only: how hard the weights are pulled back toward task A's.

0.30

Replay only: share of each batch drawn from task A.

100

Gradient steps on task A, then the same number on task B.

0.10

Step size in both phases.

0.04A before2.80A after0.04B after
  • Task A's loss contours
  • Task B's loss contours
  • Training on A
  • Then on B
Task A loss after B
2.802
Task B loss
0.044
Forgetting (rise in A's loss)
2.758
Fine-tuning's forgetting
2.758
  • Puzzle: Keep task A's loss under 0.15 while bringing task B's under 1.0.
  • Puzzle: With replay, cut forgetting to under a quarter of plain fine-tuning's.
Plain fine-tuning: task A's loss goes from 0.044 to 2.802 while task B's ends at 0.044. Plain fine-tuning would forget 2.76. Task A's Fisher information is 1.35 for the first weight and 0.041 for the second: A barely cares about the second weight, so a pull that treats both weights alike also blocks what B needs.

Plain fine-tuning: task A's loss goes from 0.044 to 2.802 while task B's ends at 0.044. Plain fine-tuning would forget 2.76. Task A's Fisher information is 1.35 for the first weight and 0.041 for the second: A barely cares about the second weight, so a pull that treats both weights alike also blocks what B needs.

04

Continue training in CodeSplash

In the app

Open a finished neural-network run and choose Make a model from this → Continue training:

  • Replay rows: a sample of the model's own training rows, trained on again with the new rows and never scored; Replay weight sets how much each counts.
  • Anchor: Toward its weights (L2-SP), By importance (EWC) or none, with an Anchor strength. EWC estimates importance on the replay rows, so it needs some.

The new run records its parent in Lineage, and because it trains on the parent's rows again, erasing those rows everywhere erases it too.

05

Measure both sides

Read

A continued model has two scores that matter: on the new data, and on held-out old data. Report both, against the parent model on the same rows. A large gain on new rows with a large loss on old ones may be the right trade, or not, but it should be visible. Try a few anchor strengths and replay sizes; there's rarely one setting that wins on both.

06

Predict: anchor strength

Predict

Predict first

You raise the EWC strength a lot. Compared with a weak anchor, how do the old and new scores usually move?

Better on old rows, worse on newBetter on bothWorse on both
Reveal

Better on old rows, worse on new. A strong anchor keeps the important weights near the parent's, which protects the old fit and limits how far the network can adapt.

07

What runs here

Read
08

Common mistakes

Read
09

Check: continual learning

Checkpoint

Check yourself

In EWC, what does the Fisher term Fi decide?

Show the answer

Answer: a

Weights with large Fisher values changed the old fit the most, so moving them costs more.

Check yourself

EWC with λ = 1: a weight with importance F = 5 moved by 1 from its old value; another with F = 0 moved by 3. What is the penalty, (λ/2)·Σ F·Δ²?

Show the answer

Answer: 2.5

(1/2) × (5 × 1² + 0 × 3²) = 2.5. The unimportant weight moves freely.

Check yourself

Why does CodeSplash's Continue training require replay rows for the EWC anchor?

Show the answer

Answer: a

Without old rows there is nothing to estimate the Fisher information from.

Check yourself

With α = 0.6, the new-row loss is 0.4 and the replayed old-row loss is 0.25. What is the mixed loss α·L_new + (1 − α)·L_old?

Show the answer

Answer: 0.34

0.6 × 0.4 + 0.4 × 0.25 = 0.24 + 0.10 = 0.34.

Check yourself

What is the main cost of experience replay compared with an anchor such as L2-SP?

Show the answer

Answer: a

Anchors keep only old weights (and importances); replay keeps old rows, which is why erasing those rows erases the continued model too.

10

Recap

Recap
  • Training on new rows alone overwrites old skills; continual learning trades plasticity for stability.
  • Replay mixes old rows into the loss; EWC pulls important weights back; L2-SP pulls all weights equally.
  • CodeSplash's Continue training offers replay rows and an L2-SP or EWC anchor, recorded in Lineage.
  • Report the old-data and new-data scores together, against the parent.

Concepts in this lesson