The question: why does a standard neural network stop learning new tasks over a long stream, and why does uniform L2 decay hit a ceiling?
Prerequisites: M6, M7 · Runtime: ~5 seconds on CPU.
When people say “continual learning is hard,” they almost always mean catastrophic forgetting: learning task 10 erases task 1. In 2024, Dohare, Hernandez-Garcia, Lan, Rahman, Mahmood, and Sutton (Nature) put an equally fundamental failure on the map: loss of plasticity. Train a standard ReLU network with SGD or Adam on a sequence of changing tasks — even if you only score it on the current task — and its performance slowly degrades until it learns worse than a freshly initialized network.
This module reproduces loss of plasticity on a tiny CPU regression stream in seconds, measures the three internal symptoms Dohare et al. track (growing weight norms, dormant units, and collapsing effective rank), and shows why the obvious fix — uniform L2 weight decay — helps at first and then hits a hard ceiling.
Distinguish retroactive forgetting (remembering task 1 at step \(t\)) from proactive loss of plasticity (learning task \(t\) cleanly at step \(t\)).
Measure the three internal correlates of plasticity loss: weight norm \(\|W\|_F\), fraction of dormant ReLU units, and effective rank\(\operatorname{erank}(H)\) of hidden representations.
Show concretely on a continual stream how plain SGD loses plasticity, how L2 weight decay partially rescues it, and how Shrink-and-Perturb goes further by re-injecting fresh directions.
Why it exists (the role it plays)
Standard deep learning assumes a one-shot lifecycle: start from a clean random initialization \(W_0\) (small weights, full-rank features, half the ReLUs active), train once on a stationary dataset, and stop. Backprop was never asked to keep \(W_t\) as easy to optimize at step \(t = 100{,}000\) as \(W_0\) was at step \(0\).
When the data distribution keeps shifting, three slow drifts accumulate inside the weights: 1. Weight norms grow: gradients push weights further from zero, making pre-activations large and pushing nonlinearities into flat/saturated regions. 2. Units go dormant: ReLU neurons whose pre-activation stays negative on all inputs output zero and receive zero gradient forever — shrinking the network’s usable width. 3. Effective rank collapses: surviving hidden features align onto a low-dimensional subspace, leaving few independent directions to fit a new target function.
Reading
Maintaining Plasticity in Deep Continual Learning (Dohare et al., Nature 2024): demonstrates plasticity loss across Continual ImageNet, Permuted MNIST, and continual PPO, and compares L2, Shrink-and-Perturb, and Continual Backpropagation (CBP).
1. Watching a ReLU MLP lose plasticity on a shifting stream
Let’s build the cleanest possible continual-learning toy: a 2-layer ReLU MLP (d_in=16 → hidden=32 → d_out=1) trained with SGD on a sequence of 40 tasks. Every task generates a fresh random nonlinear teacher target over the same input distribution and gives the student 60 gradient steps to fit it. We never test old tasks — we only measure the final MSE on each new task (pure online plasticity!).
We compare three optimizers on the exact same task sequence: 1. Plain SGD (no decay, no noise) 2. SGD + L2 weight decay (shrinks weights every step) 3. SGD + Shrink-and-Perturb (shrinks weights and adds tiny Gaussian noise each task)
import torchimport torch.nn as nnimport matplotlib.pyplot as pltdef eff_rank(H):# Effective rank of representation matrix H (N x h): exp(entropy of normalized singular values) s = torch.linalg.svdvals(H - H.mean(0, keepdim=True)) p = s / (s.sum() +1e-12) p = p[p >1e-12]return torch.exp(-(p * p.log()).sum()).item()def run_stream(mode="plain", n_tasks=40, steps_per_task=60, wd=0.0, perturb=0.0): torch.manual_seed(0) d_in, h =16, 32 net = nn.Sequential(nn.Linear(d_in, h), nn.ReLU(), nn.Linear(h, 1)) opt = torch.optim.SGD(net.parameters(), lr=0.08, weight_decay=wd)# Fixed probe inputs to measure dormant units & representation effective rank X_probe = torch.randn(128, d_in) task_mse, w_norms, dead_fracs, eranks = [], [], [], []for task inrange(n_tasks):# Fresh random teacher target for this task X = torch.randn(96, d_in) w_t1 = torch.randn(d_in, 8) *1.2 w_t2 = torch.randn(8, 1) *1.5 y = torch.tanh(X @ w_t1) @ w_t2if perturb >0.0and task >0:with torch.no_grad():for p in net.parameters(): p.mul_(0.85).add_(torch.randn_like(p) * perturb)for _ inrange(steps_per_task): pred = net(X) loss = ((pred - y) **2).mean() opt.zero_grad(); loss.backward(); opt.step()with torch.no_grad(): final_mse = ((net(X) - y) **2).mean().item() H = net[1](net[0](X_probe)) dead = (H.abs().max(dim=0).values <1e-5).float().mean().item() er = eff_rank(H) wn =sum(p.norm().item() for p in net.parameters()) task_mse.append(final_mse); w_norms.append(wn) dead_fracs.append(dead); eranks.append(er)return task_mse, w_norms, dead_fracs, eranksmse_p, wn_p, dead_p, er_p = run_stream("plain", wd=0.0)mse_l2, wn_l2, dead_l2, er_l2 = run_stream("l2", wd=0.03)mse_sp, wn_sp, dead_sp, er_sp = run_stream("sp", wd=0.01, perturb=0.08)print("Metric at Task 1 -> Task 40:")print(f" Plain SGD | MSE: {mse_p[0]:.3f} -> {mse_p[-1]:.3f} | norm: {wn_p[0]:.1f}->{wn_p[-1]:.1f} | dead: {dead_p[-1]*100:.0f}% | erank: {er_p[0]:.1f}->{er_p[-1]:.1f}")print(f" SGD + L2 (0.03) | MSE: {mse_l2[0]:.3f} -> {mse_l2[-1]:.3f} | norm: {wn_l2[0]:.1f}->{wn_l2[-1]:.1f} | dead: {dead_l2[-1]*100:.0f}% | erank: {er_l2[0]:.1f}->{er_l2[-1]:.1f}")print(f" Shrink & Perturb | MSE: {mse_sp[0]:.3f} -> {mse_sp[-1]:.3f} | norm: {wn_sp[0]:.1f}->{wn_sp[-1]:.1f} | dead: {dead_sp[-1]*100:.0f}% | erank: {er_sp[0]:.1f}->{er_sp[-1]:.1f}")fig, axes = plt.subplots(1, 3, figsize=(10.5, 2.9))axes[0].plot(mse_p, label="Plain SGD", color="#c85a53")axes[0].plot(mse_l2, label="SGD + L2", color="#2563eb")axes[0].plot(mse_sp, label="Shrink & Perturb", color="#1f6f66", lw=2)axes[0].set_title("New-task MSE (lower = more plastic)"); axes[0].set_xlabel("task"); axes[0].legend(fontsize=7.5)axes[1].plot(wn_p, color="#c85a53"); axes[1].plot(wn_l2, color="#2563eb"); axes[1].plot(wn_sp, color="#1f6f66", lw=2)axes[1].set_title("Weight norm ||W||_F"); axes[1].set_xlabel("task")axes[2].plot(er_p, color="#c85a53"); axes[2].plot(er_l2, color="#2563eb"); axes[2].plot(er_sp, color="#1f6f66", lw=2)axes[2].set_title("Hidden effective rank"); axes[2].set_xlabel("task")plt.tight_layout(); plt.show()
Look at the three panels together: - Plain SGD climbs in weight norm, loses hidden effective rank, accumulates dormant ReLU units, and its new-task error drifts steadily upward — even though every task is drawn from the exact same difficulty distribution. - L2 weight decay caps the weight norm, which helps noticeably, yet notice what happens if you crank L2 too high: uniform shrinkage pulls every weight toward zero (shrinking effective rank and underfitting the current task) without reviving dead ReLUs. - Shrink-and-Perturb caps norm and injects tiny fresh directions, keeping effective rank high and MSE low across all 40 tasks.
Because isotropic noise perturbs every weight indiscriminately — including the weights holding useful knowledge from previous tasks! If you only care about plasticity on the new task, Shrink-and-Perturb looks great; if you also need to remember earlier tasks (stability), uniform shrinkage + uniform noise erases them. That is the exact dilemma PC-2’s utility-guided methods (CBP, UPGD, SWR) solve.
Honest scope. A 40-task, 32-unit MLP shows the mechanics in 5 seconds; Dohare et al. run thousands of tasks on Continual ImageNet, Permuted MNIST, and PPO to show that the same three correlates (norm growth, dormancy, rank collapse) drive severe plasticity loss at scale.
Exit check
What is the difference between catastrophic forgetting and loss of plasticity?
Name the three internal network diagnostics that track loss of plasticity.
Why does uniform L2 weight decay help at first, yet fail to fully restore plasticity (or hurt stability when cranked too high)?