Adaptive Class Aware Memory Selection and Contrastive Representation Learning for Robust Online Continual Learning in both Balanced and Imbalanced Data Environments

Rui Yang, Matthieu Grard, Emmanuel Dellandréa, Liming ChenSPIRE 2025

Abstract

Online Continual Learning (OCL) is a framework where models learn continuously from a stream of data without revisiting previously seen data. This is crucial for many real-life applications, e.g., autonomous driving, healthcare monitoring, and robotics, where data evolves over time. However, current state-of-the-art continuous learning methods struggle with dynamic and unbalanced data, often failing to adapt and leading to severe performance degradation. In this paper, we introduce Memory Selection with Contrastive Learning (MSCL), an advanced approach to Continual Learning (CL) designed to tackle these challenges. MSCL integrates Feature-Distance Based Sample Selection (FDBS) for effective memory adaptation, emphasizing inter-class similarities and intra-class diversity, with a novel contrastive learning loss (SCL) for evolving data representation consolidation. Our extensive evaluations on datasets including CIFAR-100, Mini-ImageNet, PACS, and DomainNet demonstrate that MSCL not only surpasses existing memory-based CL methods on data balanced scenarios, but also excels particularly in imbalanced scenarios, thereby establishing a novel state of the art in both balanced and imbalanced learning contexts.

1. Introduction

In the ideal world of machine learning, data is shuffled and balanced. However, in real-world applications like autonomous driving or medical monitoring, data arrives as a non-stop stream where "task boundaries" are invisible, and some classes or environments (domains) appear far more frequently than others. Standard models suffer from catastrophic forgetting: as they learn new information, they abruptly lose what they previously knew.

Existing "rehearsal-based" solutions attempt to mitigate this by maintaining a small "buffer" of old data to replay during training. However, most current methods rely on simple strategies like random sampling to fill this buffer. These strategies often fail when data is imbalanced because they do not account for the increasing diversity within a class or the shrinking boundaries between similar classes, leading to poor performance when the data distribution shifts.

2. Methodology: The MSCL Framework

To address these limitations, we propose MSCL (Memory Selection with Contrastive Learning). MSCL consists of two synergistic components designed to optimize both the data stored in memory and the way the model learns from it.

MSCL Framework Overview

2.1 Feature-Distance Based Sample Selection (FDBS)

Instead of picking samples at random, FDBS calculates an "importance weight" for every new piece of data. It prioritizes samples that are either very different from what's already in memory (promoting intra-class diversity) or very close to samples from other classes (capturing inter-class boundaries). This ensures the memory buffer contains the most "informative" examples rather than just the most common ones. By focusing on these critical samples, FDBS maintains a more representative memory buffer even under severe class imbalance.

2.2 Supervised Contrastive Learning (SCL)

To make the model’s internal representations more robust, we employ a contrastive loss. This pulls similar class examples together in the feature space and pushes different classes apart. Crucially, we introduce an Importance Weight-based Loss (IWL) that utilizes the weights derived from FDBS. This allows the model to focus its learning capacity on the most critical samples during training, effectively "rehearsing" more intensely on samples that are hardest to distinguish.

3. Experimental Evaluation

The researchers evaluated MSCL on several standard benchmarks and introduced new "imbalanced" versions to simulate real-world difficulty:

  • Standard (Balanced): Split Mini-ImageNet, Split CIFAR-100, and PACS (Photo, Art, Cartoon, Sketch).
  • Imbalanced Benchmarks: We introduced Imb CIL (Class-Incremental), Imb DIL (Domain-Incremental), and Imb C-DIL (Combined Class and Domain imbalance) versions of the above datasets.
  • DomainNet: A large-scale dataset used in its original, naturally imbalanced format.

3.1 Results and Discussion

MSCL consistently outperformed existing state-of-the-art (SOTA) methods like OnPro and ER across all tests.

Performance Comparison in Imbalanced Scenarios

As shown in the results table, MSCL's strengths are most evident in imbalanced scenarios. In the challenging "Imbalanced Class-Incremental" CIFAR-100 test, it reached 24.8% accuracy, while other methods struggled significantly lower (e.g., OnPro at 22.3%). Similarly, in the Imb C-DIL scenario on PACS, MSCL achieved 30.6%, a significant lead over competitors.

In balanced scenarios, MSCL also set new benchmarks. On Mini-ImageNet (with a 5k memory buffer), MSCL achieved 36.9% accuracy, surpassing the previous SOTA of 34.5%. Furthermore, MSCL showed the lowest "Average Forgetting" rates across the board. For example, on imbalanced PACS, its forgetting rate was only 17.5%, compared to 20.4% for the next best method.

4. Conclusion

MSCL demonstrates that diversity and boundary awareness are critical for robust online continual learning. By prioritizing "informative" outliers and boundary cases over frequent "average" cases, and reinforcing these through a weighted contrastive loss, MSCL effectively mitigates catastrophic forgetting in complex, imbalanced environments. Future work will explore combining MSCL with distillation-based methods to reduce reliance on raw data storage and testing the framework on more complex architectures.

Summary updated

BibTeX
@inproceedings{yang2025adaptive,
  author = {Rui Yang and Matthieu Grard and Emmanuel Dellandréa and Liming Chen},
  title = {{Adaptive Class Aware Memory Selection and Contrastive Representation Learning for Robust Online Continual Learning in both Balanced and Imbalanced Data Environments}},
  booktitle = {SPIRE},
  year = {2025},
}
Figure