Lesson 2 of 9 in this unit
Learn something new without losing the old.
Train a shared neural network on two tasks, measure forgetting, and compare replay with a parameter-change penalty.
By the end: Explain interference between shared weights, compare retention and new learning, and distinguish replay, regularization, modularity, and memory.
Prerequisites and path options
Why learn this? Protect an existing skill while teaching a model a new one, using explicit checks for regressions.
Start with something concrete.
Learning a new keyboard layout can interfere with familiar typing habits. A neural network can have a similar problem: changing shared parameters to improve a new task can damage an older behavior.
Try the interactive modelTask B’s training loss falls. What does this tell you about task A?
Change one thing. Watch what follows.
Loading this browser experiment…
Understand what changed.
A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.
The idea in everyday terms
Learning a new task changes shared weights. Those changes can damage an older task even when the two tasks are both representable. The new examples do not automatically remind the model of everything it learned before.
What to watch in the experiment
Replay mixes old examples into later training. Anchoring discourages changes away from earlier weights. Compare the old-task and new-task errors together under the same training budget; protecting one task can slow improvement on another.
What this does not establish
Neither replay nor anchoring guarantees that every old skill survives. The lab uses controlled tasks, so its comparisons do not establish broad continual-learning ability.
Open the full worked examples, calculations and limitations
This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.
Shared weights can support several skills
Catastrophic forgetting occurs when learning new tasks substantially damages earlier capabilities. The new gradient optimizes the examples it sees; it does not automatically preserve behaviors absent from that training batch.
Our two tasks occupy different input regions. A labels left-side points by whether y is positive. B labels right-side points by whether y is negative. A nonlinear network can represent both rules together. They are not contradictory labels for identical inputs, so poor retention need not be an unavoidable conflict in the task definition.
Train A, save the checkpoint, and then train B. Compare both independently sampled evaluation sets after each stage. B’s improvement can coincide with A’s collapse. Inspecting only the latest task would hide the regression.
A local way to understand interference
For a small parameter change, the old loss changes approximately by the old gradient dotted with that parameter change:
If a B update moves in a direction that increases A’s loss, interference occurs. The walkthrough calculates this approximation and compares it with the actual one-step change on A’s training examples. It does not use evaluation examples to choose gradients. A first-order approximation can differ from the exact change when curvature or step size matters.
Replay preserves experience
Replay includes old examples in new training. The old gradients can then influence shared parameters instead of disappearing from the objective. In the lab, replay uses 32 stored A examples and 32 B examples per update. New-only training uses 64 B examples. Both process 64 examples, but their exposure to B differs; state that tradeoff when comparing them.
Representative memory matters. A replay buffer that omits rare old cases may fail to protect them. Storing all prior data can be expensive or inappropriate, and no fixed buffer guarantees indefinite retention. Measure old and new performance separately rather than hiding one behind an average.
Penalties and modular updates
A parameter-change penalty discourages moving away from an earlier solution. Our anchor strategy pulls every parameter toward the A checkpoint with the same coefficient. Stronger protection can also make learning B harder. This is a simple regularizer, not full Elastic Weight Consolidation (EWC).
EWC weights the penalty using estimates of which parameters mattered to prior tasks. Its importance estimates and assumptions can be imperfect. Modularity takes another approach: isolate some updates in specialists or adapters while freezing shared parts. The source’s chess-and-Go example uses separate adapters over a shared frozen backbone to reduce interference. Isolation also limits what can be shared or improved jointly.
None of these methods removes genuine contradictions or unlimited capacity demands. The separate scalar example makes that limit explicit:
| Weight | Old loss (w − 2)² | New loss (w + 2)² |
|---|---|---|
| 2 | 0 | 16 |
| 0 | 4 | 4 |
| −2 | 16 | 0 |
Equal replay favors a compromise at zero, with average loss four. It cannot make one scalar equal to both two and minus two.
Remembering need not mean updating weights
An agent can update working state during inference, store an episode between tasks, and train its neural components later. These are different timescales. New library API details might belong in a retrievable knowledge record; a repeated debugging skill might eventually justify parameter training.
External memory can store new facts without immediately altering model weights, though retrieval and outdated records create their own problems. Deciding what to store, retrieve, consolidate, or forget is part of the system design. We will explore that directly in the memory module.
For old loss (w−2)² and new loss (w+2)², what are the losses at w = 0?
Take this idea with you.
Measure old and new behavior after updates. Replay, penalties, and modularity can reduce interference, while external memory can store some new information without changing weights.
Explore related topics and the topic map
How this topic connects
Explore this topic on the interactive mapUse these connections to review a foundation or choose where to go next. You can open any topic without completing the others.
What it builds on
- Backpropagation
Trace a wrong update to its source so you can debug learning code and distinguish calculating gradients from changing weights.
- Classifier project
Use the classifier workbench to connect fitted parameters, predictions and separate evaluation examples before extending the experiment.
- Promotion gates
Build practice loops that reward correct results instead of letting a weak checker reinforce mistakes.
Train a shared neural network on two tasks, measure forgetting, and compare replay with a parameter-change penalty.
What it enables
- Learn a better way to adapt
Understand when learning a starting point can make later adaptation more efficient.
- Choose where a connected system learns
Choose which components to retrain while protecting the other systems that depend on their outputs.
- Choose what experience to retain
Choose retained experience using coverage and budget evidence instead of assuming that a larger replay count means more independent information.
Show 1 more connections
- Learn reusable temporally extended skills
Test learned option actions and stopping decisions separately from a fixed hierarchy before claiming reusable learned skills.