Bypassing Gradients Re-Projection with Episodic Memories in Online Continual Learning

Yu Chen, Tom Diethe, Peter A. Flach

Abstract

The use of episodic memory in continual learning has demonstrated effectiveness for alleviating catastrophic forgetting. In recent studies, gradient-based approaches have been developed to make more efficient use of compact episodic memory. Such approaches refine the gradients resulting from new samples by those from memorized samples, aiming to reduce the diversity of gradients from different tasks. In this paper, we clarify the relation between diversity of gradients and discriminativeness of representations, showing shared as well as conflicting interests between Deep Metric Learning and continual learning, thus demonstrating pros and cons of learning discriminative representations in continual learning. Based on these findings, we propose a simple method -- Semi-Discriminative Representation Loss (SDRL) -- for continual learning. In comparison with state-of-the-art methods, SDRL shows better performance with low computational cost on multiple benchmark tasks in the setting of online continual learning.

Introduction

The "holy grail" of machine learning is continual learning: the ability for a model to learn new tasks sequentially without "catastrophic forgetting," where learning a new task causes the model to lose performance on previously learned ones. In the online setting, this challenge is amplified because the model only observes each data point once.

Current state-of-the-art methods often utilize a small "episodic memory" of past samples. Gradient-based approaches, such as GEM and A-GEM, attempt to ensure that updates for new data do not conflict with the requirements of old data by projecting gradients. However, these methods are computationally expensive, requiring complex optimization that scales poorly with model size.

Semi-Discriminative Representation Loss (SDRL)

The proposed Semi-Discriminative Representation Loss (SDRL) shifts the focus from post-hoc gradient correction to optimizing the underlying representations (internal features). By shaping the representation space, SDRL prevents gradient conflicts from arising initially.

SDRL introduces two primary components:

  1. Between-class Loss ($L_{bt}$): This minimizes the similarity between representations of different classes, pushing distinct categories further apart in the feature space to increase discriminativeness.
  2. Within-class Loss ($L_{wi}$): This "semi-discriminative" component actually minimizes similarity within the same class. Unlike standard Deep Metric Learning, which seeks maximum compactness, SDRL prevents the model from discarding "extra" information that might be crucial for distinguishing future, unseen classes.

To facilitate these losses, the authors introduce Balanced Experience Replay (BER), a sampling strategy ensuring each training batch contains a diverse class mix and at least one "positive pair" (two samples from the same class).

Key Insights: The Source of Conflict

A core finding of this work is that gradient diversity—and thus conflicting updates—is highest for samples located near decision boundaries. When different classes have highly similar internal representations, updating the model for one class is likely to negatively impact the other.

Figure 1: Spatial distribution of data and regions of potential gradient conflict ($S_0$ near the boundary vs. $S_1, S_2, S_3$).

Empirical analysis reveals a strong correlation between representation similarity and gradient similarity. For samples of different classes, reducing representation similarity tends to align their gradients more closely (or at least reduce conflict), justifying the $L_{bt}$ loss. Conversely, the high gradient similarity within classes suggests that over-compressing these representations (high representation similarity) might lead to the loss of generalizable features, supporting the "anti-compactness" approach of $L_{wi}$.

Figure 3: Relationship between the similarity of representations and the similarity of gradients for same-class and different-class pairs.

Experimental Results

The authors evaluated SDRL on standard benchmarks including Permuted MNIST, Split MNIST, Split CIFAR-10/100, and Split TinyImageNet.

  • Accuracy: SDRL consistently outperformed state-of-the-art methods. On Split CIFAR-100, it achieved 19.3% accuracy, surpassing A-GEM's 16.5%.
  • Forgetting: On the challenging TinyImageNet benchmark, SDRL demonstrated superior retention with 27.0% forgetting, compared to 28.5% for standard Experience Replay.
  • Efficiency: SDRL offers a massive speedup. Because it scales with the size of the representation layer rather than the total number of model parameters, it is orders of magnitude faster than gradient re-projection methods. On CIFAR-10 with a ResNet18, SDRL trained in 265 seconds, while the gradient-based GSS method required 5,289 seconds.

Conclusion

SDRL provides a computationally efficient and effective alternative to complex gradient-based continual learning methods. By fostering semi-discriminative representations, it mitigates catastrophic forgetting while preserving essential features for future tasks. Future work may explore more sophisticated episodic memory construction to further enhance the model's ability to preserve general information across tasks.

Summary updated

BibTeX
@inproceedings{chen2021bypassing,
  author = {Yu Chen and Tom Diethe and Peter A. Flach},
  title = {{Bypassing Gradients Re-Projection with Episodic Memories in Online Continual Learning}},
  booktitle = {Bristol},
  year = {2021},
}
Figure