NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Continual learning with hypernetworks

Johannes von Oswald, Christian Henning, João Sacramento, Benjamin F. Grewe

Overview

This paper introduces a novel approach to continual learning (CL) by using task-conditioned hypernetworks—metamodels that generate the weights for a target neural network based on a specific task identity. By applying a simple regularizer to the hypernetwork's output rather than the target network's weights, the authors achieve state-of-the-art performance on major benchmarks while maintaining a "compressive regime" where the hypernetwork is smaller than the model it generates.

Introduction: The Catastrophic Forgetting Problem

Artificial neural networks are notoriously bad at "continual learning." When trained on a sequence of tasks, they suffer from catastrophic forgetting: learning a new task typically overwrites the weights necessary for previous tasks, causing performance on older data to plummet.

Existing solutions usually fall into two camps:

  1. Rehearsal: Storing and re-playing old data, which raises privacy and memory concerns.
  2. Regularization: Penalizing changes to "important" weights, which often restricts the model too much and leads to poor performance on new tasks.

The authors argue that the problem is easier to solve at the meta-level. Instead of trying to keep the target network's weights stable, they propose managing a "weight generator" that knows exactly which weights to produce for any given task.

The Task-Conditioned Hypernetwork Approach

The core of the proposal is the Task-Conditioned Hypernetwork.

Architecture of the regularized and chunked hypernetwork.
  • The Hypernetwork ($f_h$): This is a secondary model that takes a small task embedding (a vector representing a specific task) as input and outputs the full set of weights ($\Theta$) for a target network.
  • Output Regularization: When learning a new task $T$, the authors don't just minimize the loss for that task. They also add a regularization term that penalizes the hypernetwork if it changes the weights it would have generated for previous tasks $1$ through $T-1$.
  • Chunking: To avoid the hypernetwork becoming massive (since it has to output millions of weights), the authors use a "chunked" approach. The hypernetwork generates the target weights in small pieces, allowing it to remain compact and even smaller than the target network itself.
  • Task Inference: In scenarios where the task ID isn't known at test time, the authors propose two methods: HNET+ENT (choosing the task embedding that results in the lowest prediction uncertainty) and HNET+R (using a generative model to "replay" synthetic data to infer the task).

Experimental Setup & Datasets

The authors evaluated their approach on several standard CL benchmarks:

  • Permuted MNIST: A sequence of tasks where the pixels of MNIST digits are randomly shuffled differently for each task.
  • Split MNIST: A sequence of five binary classification tasks (0 vs 1, 2 vs 3, etc.).
  • Split CIFAR-10/100: A challenging benchmark starting with the full CIFAR-10 dataset followed by ten-class splits from CIFAR-100.
  • 1D Regression: A toy problem used to visualize how the model retains polynomial functions of increasing degrees.

Key Insights

  • Weight Rehearsal vs. Data Rehearsal: The most elegant "aha moment" is that instead of remembering thousands of images per task, the system only needs to remember a single point in the hypernetwork's input space (the task embedding).
  • The Compressive Regime: Remarkably, the hypernetwork can achieve high performance even when it has fewer trainable parameters than the target network. This suggests that the "manifold" of useful weights for a set of tasks is low-dimensional.
  • Forward Transfer: Because the hypernetwork is shared across tasks, it naturally learns features that are useful for future tasks. The experiments showed that the model finds better solutions faster when it has "seen" related tasks before.

Performance and Results

1D regression task demonstrating catastrophic forgetting in standard fine-tuning (c) versus retention with hypernetwork regularization (a).
  • 1D Regression (Visualizing Memory): As shown in the toy regression task above, standard fine-tuning completely forgets previous polynomial functions, whereas the hypernetwork successfully retains them.
  • Permuted MNIST (100 tasks): While standard methods like Synaptic Intelligence (SI) and EWC saw performance degrade as the sequence grew, the hypernetwork (HNET) maintained a steady accuracy of ~96% across all 100 tasks.
  • Split MNIST: HNET+R (with synthetic replay) achieved 99.83% accuracy on CL1 (task identity known) and 95.30% on CL3 (task identity unknown), outperforming the previous state-of-the-art (DGR+distill).
  • Zero Forgetting on Complex Models: On the Split CIFAR-10/100 benchmark using a ResNet-32, the hypernetwork-protected model showed virtually zero forgetting, maintaining its performance on the initial CIFAR-10 task even after learning five subsequent CIFAR-100 tasks.
  • Efficiency: The authors demonstrated that they could compress the model significantly—maintaining high accuracy even when the hypernetwork was only 1% the size of the total weights it was capable of generating.

Limitations and Future Directions

  • Task Boundaries: The current training setup generally requires knowing when one task ends and another begins to save the task embedding and update the regularizer.
  • Linear Growth: While task embeddings are tiny, the number of embeddings still grows linearly with the number of tasks. For thousands of tasks, this might eventually become a bottleneck.
  • Backward Transfer: The current regularizer is designed to prevent change (no forgetting), which limits "positive backward transfer"—the ability for a new task to actually improve performance on an old one. The authors suggest this as a key area for future research.
  • Task Inference: While HNET+ENT works well, it relies on the model being "calibrated" (knowing when it is uncertain), which remains a difficult problem in deep learning.

Summary updated

BibTeX
@inproceedings{oswald2020continual,
  author = {Johannes von Oswald and Christian Henning and João Sacramento and Benjamin F. Grewe},
  title = {{Continual learning with hypernetworks}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
  url = {https://openreview.net/forum?id=C9t-J0OgP1t},
}
Figure