Abstract
Gradient Episodic Memory (GEM) is a seminal method in continual learning designed to alleviate catastrophic forgetting by projecting gradient updates to satisfy non-interference constraints with past tasks. While GEM has been highly influential, a close examination of the original derivation reveals mathematical inconsistencies in the proof of its dual Quadratic Program (QP). This technical note provides a rigorous correction of the dual formulation, ensuring the mathematical foundation for GEM's efficient gradient projection is sound.
Introduction
In the paradigm of continual learning, neural networks are tasked with learning a sequence of problems. A primary challenge in this setting is "catastrophic forgetting," where the optimization of weights for a new task significantly degrades performance on previously learned tasks. Gradient Episodic Memory (GEM), introduced by Lopez-Paz and Ranzato (2017), addresses this by maintaining a small episodic memory of data from previous tasks.
During training on a current task, GEM computes a proposed gradient update $g$. To ensure this update does not interfere with prior knowledge, GEM requires that the update does not increase the loss on any previous task. Mathematically, this is expressed as a constraint that the angle between the projected gradient $\tilde{g}$ and the gradients of past tasks $g_k$ must be non-acute. When a conflict occurs, GEM projects $g$ onto a feasible region defined by these constraints.
The Gradient Projection Problem
The projection is framed as a Quadratic Program (QP). The goal is to find a projected gradient $\tilde{g}$ that is as close as possible to the original gradient $g$ in terms of $L_2$ distance, while satisfying the non-interference constraints:
Minimize: $\frac{1}{2} \|\tilde{g} - g\|_2^2$ Subject to: $\langle \tilde{g}, g_k \rangle \ge 0$ for all $k < t$
Given that neural networks often possess millions of parameters ($p$), solving this primal problem directly is computationally prohibitive. GEM circumvents this by solving the dual problem, which scales with the number of tasks ($t$)—typically a much smaller value. However, the original derivation of this dual problem contained errors that this note seeks to rectify.
Methodology: Correcting the Dual Derivation
The correction is achieved through a systematic application of Lagrangian duality. The process involves four key steps:
- Standardization: The GEM objective and constraints are mapped to the standard form of a QP. Let $G$ be the matrix representing the gradients of previous tasks. The constraints are reformulated to fit the standard inequality structure.
- Lagrangian Formulation: A Lagrangian function is constructed for the standardized QP. This step requires careful attention to matrix dimensions, particularly the relationship between the high-dimensional parameter space $p$ and the low-dimensional task space $t$.
- Dual Derivation: The dual function is derived by finding the infimum of the Lagrangian with respect to the primal variables. This is done by setting the gradient of the Lagrangian to zero and solving for the primal variables in terms of the dual variables.
- Variable Substitution: The specific variables of the GEM problem are substituted back into the general dual form to produce a corrected, efficient QP.
Key Results
The corrected derivation yields a dual QP that operates only on $t-1$ variables. To find the optimal projected gradient, one must solve for the dual variable $v$:
Minimize: $\frac{1}{2} v^\top G G^\top v - g^\top G^\top v$ Subject to: $v \ge 0$
Once the optimal dual solution $v^*$ is obtained, the high-dimensional projected gradient $\tilde{g}$ is recovered using the following relationship:
$\tilde{g} = -G^\top v^* + g$
In this formulation, $G$ represents the matrix of negated gradients from previous tasks, and $g$ is the proposed gradient for the current task. This corrected recovery formula ensures that the resulting update $\tilde{g}$ strictly adheres to the non-interference constraints while remaining as close to the original gradient as possible.
Conclusion
This note provides the necessary mathematical corrections to the dual QP derivation in the Gradient Episodic Memory framework. While the original proof contained errors, the fundamental insight of GEM—that gradient projection can be efficiently solved in the dual space—remains valid. By providing a rigorous derivation, this work ensures that the mathematical implementation of GEM is consistent with its theoretical objectives, preserving its utility for the continual learning community.
Summary updated