Continual Learning in Deep Networks: an Analysis of the Last Layer

Timothée Lesort, Thomas George, Irina Rish

TL;DR

This paper demonstrates that catastrophic forgetting in deep continual learning can be significantly mitigated simply by changing the parameterization and update rules of the network's final output layer. By isolating the output layer from the feature extractor, the authors show that replacing standard linear layers with angle-based alternatives (CosLayer or WeightNorm) and applying target masking can dramatically reduce interference and weight degradation without needing complex continual learning algorithms.

What Problem Does This Paper Address?

In continual learning (CL), deep neural networks notoriously suffer from catastrophic forgetting: when trained on new tasks, they rapidly overwrite what they learned previously. While most research focuses on regularizing or expanding the entire network, this paper zeroes in on a specific, highly vulnerable bottleneck: the final classification layer.

When a standard linear layer ($o = Az + b$) is trained sequentially on new classes, the optimization dynamics naturally cause the weights and biases of recently seen classes to grow much larger in norm than those of past classes. This creates a severe imbalance, biasing the network to predict only the newest classes. The authors break down output-layer forgetting into three distinct sources:

  1. Weight modifications: The optimizer inadvertently alters weights of past classes when learning new ones.
  2. Interference: Similarities in the latent space cause overlap and confusion between classes.
  3. Projection drift: The feature extractor changes over time, shifting the underlying embedding space.

By freezing the feature extractor, the authors isolate and tackle the first two issues directly.

Methods

The authors propose and evaluate two main strategies to fix the output layer: reparameterization and gradient masking.

1. Reparameterizations

Instead of a standard linear layer, they test alternative mathematical formulations that eliminate bias and norm imbalances:

  • Linear without bias (Linear_no_bias): Removes the bias vector $b$.
  • Simplified Weight Normalization (WeightNorm): Forces the class weight vectors to have a unit norm, meaning the output depends only on the latent vector's norm and its angle with the class weight: $||z|| \cdot \cos(\angle(z, A_i))$.
  • Cosine Layer (CosLayer): Strips away the latent norm entirely, making the prediction purely a function of the angle: $\cos(\angle(z, A_i))$.

2. Masking Strategies

To prevent the optimizer from modifying weights of classes not present in the current training batch, they introduce:

  • Single Masking: Only the weights corresponding to the true target class are updated during the backward pass.
  • Group Masking: Weights for all classes not present in the current mini-batch are masked out.

They also benchmark these against non-gradient classifiers like $k$-Nearest Neighbors (KNN), Nearest Mean Classifiers (MeanLayer), and Streaming Linear Discriminant Analysis (SLDA).

Datasets

The approaches were evaluated across several distinct continual learning setups using standard computer vision benchmarks:

  • Incremental Scenarios (New classes over time): CIFAR10, Core50, and CUB200.
  • Lifelong Scenarios (Same classes, changing environments/domains): Core10Lifelong and CIFAR100Lifelong.
  • Mixed Scenario (Combination of class and domain drift): Core10Mix.

Key Insights and Ideas

  • The Tyranny of Norm and Bias: Standard linear layers fail in incremental learning because the norms and biases of active classes skyrocket, drowning out past knowledge.
Illustration of norm and bias unbalance at the end of a CIFAR10 continual experiment.
  • Angles Over Magnitudes: Reparameterizations like CosLayer and WeightNorm perform exceptionally well because they rely on the angle between the data and the class vectors, inherently minimizing the risk of representation interference.
  • Masking is a Strict Regularizer: In class-incremental settings, simply blocking the gradient updates for inactive classes completely prevents the degradation of past weights.
Figure 2: Illustration of Forgetting: we plot the difference between weights before and after task 45 in the scenario Core10Mix (first 50 dimensions only). Task 45 is composed of only one class that is different from 44’s one. Those two figures show the impact of masking. Indeed, it avoids the modification of weights of other classes.
  • Drift Type Dictates the Solution: Masking is highly effective for incremental scenarios (where tasks introduce entirely new classes) but actually degrades performance in lifelong scenarios (where the same classes are revisited in new domains), because the network needs to update all class vectors to adapt to the domain shift.

Key Results

  • Linear Layer Alternatives Win: In incremental settings, CosLayer and WeightNorm consistently outperformed standard linear layers. When combined with single masking, CosLayer_Masked emerged as the top performer.
  • Data-Efficient Replay: When trained on small subsets of data (simulating a replay buffer), WeightNorm and CosLayer_Masked remained highly competitive, proving that these parameterizations are robust even in low-data regimes.
  • End-to-End Benefits: In an end-to-end training test on CIFAR10 using a vanilla replay buffer, incorporating group masking significantly boosted final accuracy, particularly when the replay buffer size was small (low replay balance). This suggests masking makes experience replay much more compute- and memory-efficient.

Limitations and Future Work

The primary limitation acknowledged by the authors is that their core study isolates the output layer by freezing the feature extractor, thereby ignoring projection drift (how the embedding space changes during end-to-end training). While they provide a brief proof-of-concept showing that masking helps in end-to-end replay settings, more work is needed to fully integrate these last-layer fixes with dynamically changing feature extractors.

Additionally, while similarity-based non-gradient methods like SLDA performed exceptionally well, they are non-differentiable, meaning they cannot be used to fine-tune the rest of the network during standard backpropagation. Bridging the gap between the stability of these non-gradient methods and the flexibility of gradient-based end-to-end training remains an open challenge.

Summary updated

BibTeX
@inproceedings{lesort2022continual,
  author = {Timothée Lesort and Thomas George and Irina Rish},
  title = {{Continual Learning in Deep Networks: an Analysis of the Last Layer}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=R2AN-rz4j_X},
}
Figure