Elastic Weight Consolidation Toy
Balance a new quadratic task against parameter importance from an old task.
By Riano · Published · Updated · Report a correction
Elastic Weight Consolidation Toy
Elastic Weight Consolidation (EWC) provides a mechanism to train neural networks on sequential tasks without catastrophically forgetting what was learned in earlier tasks. By retaining parameter importance across tasks, models balance acquiring new knowledge with preserving existing capabilities.
Worked Example
Consider an old task with minimizer a = [-1, 1] and importance weights F = [9, 1]. A new task has minimizer b = [1, -1] and importance G = [1, 9]. We set retention strength λ = 1. The combined objective balances the losses:
- Old task loss: L_A = 1/2∑ F_i(\theta_i - a_i)².
- New task loss: L_B = 1/2∑ G_i(\theta_i - b_i)².
- Total objective: L_B + λ L_A.
- The unique minimizer is computed as: \theta_i = (G_i b_i + λ F_i a_i)/(G_i + λ F_i).
- For parameter 1: \theta_1 = (1(1) + 1(9)(-1))/(1 + 1(9)) = -0.8.
- For parameter 2: \theta_2 = (9(-1) + 1(1)(1))/(9 + 1(1)) = -0.8.
- We calculate L_A at θ = [-0.8, -0.8]: L_A = 1/2(9(0.2)² + 1(-1.8)²) = 1.8.
Experiment
You can interactively explore the effect of λ on the parameter optimization trajectory in the Elastic Weight Consolidation Toy module.
- Set Tasks to "Complementary".
- Set Retention strength (λ) to "4".
- Observe how the consolidated minimizer shifts closer to the old task minimizer compared to λ = 1. The old task loss L_A decreases to 0.972.
- Set Tasks to "Unidentified coordinate". Notice how if a parameter has zero importance in both tasks (when λ = 0), the minimizer is technically non-unique.
Limitations
This toy model illustrates the core mechanic of EWC but simplifies several real-world aspects. Real EWC uses the diagonal of the Fisher Information matrix approximated from task data rather than manually specified importance weights. Moreover, we assume the loss landscape is perfectly quadratic, whereas real deep learning models have highly non-convex loss surfaces where EWC acts as a local quadratic approximation around the previous minimizer.
References
The original Elastic Weight Consolidation methodology was introduced in the paper:Overcoming catastrophic forgetting in neural networks by Kirkpatrick et al., 2017.
Experience it interactively
Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Elastic Weight Consolidation Toy module.
Try Elastic Weight Consolidation Toy on Riano →