Adding New Tasks to a Single Network with Weight Transformations Using Binary Masks

Massimiliano Mancini, Elisa Ricci, Barbara Caputo, Samuel Rota Bulò

Introduction

In the rapidly evolving field of deep learning, the ability to adapt a single model to multiple tasks without losing performance on previous ones—a phenomenon known as "catastrophic forgetting"—remains a significant challenge. This paper introduces a highly efficient method for multi-task adaptation by applying lightweight affine transformations to a pre-trained network's weights. By utilizing learned binary masks and a minimal set of scaling parameters, the researchers demonstrate that a network can be adapted to diverse domains, such as sketches or paintings, while adding only approximately one bit of data per parameter for each new task.

The Challenge of Catastrophic Forgetting

Standard fine-tuning typically causes a neural network to overwrite the knowledge required for its original task. To mitigate this, researchers often resort to two extremes:

  1. Fine-tuning separate models: While effective, this approach requires a full set of parameters for every new task, making it unscalable for large numbers of domains.
  2. Masking methods (e.g., Piggyback): These methods learn a binary mask to selectively activate weights of a fixed, pre-trained model. While memory-efficient, simple masking often lacks the expressive power to achieve peak performance on datasets that differ significantly from the pre-training domain.

The authors propose a middle ground that offers the performance of individual fine-tuned models with the compact memory footprint of masked models.

Proposed Methodology: Affine Weight Transformations

The core contribution of this work is the generalization of the binary masking technique into a more expressive affine transformation. Instead of simply multiplying weights by a mask, the authors propose a "Full" transformation model:

$$\tilde{W} = k_0W + k_1\mathbf{1} + k_2M + k_3(W \odot M)$$

In this equation, $W$ represents the original pre-trained weights, $M$ is a learned binary mask, and $k_0, k_1, k_2, k_3$ are learned scalar parameters (only four per layer). This structure allows the model to shift and scale the weight distribution specifically for the target task.

The Full affine transformation process, showing how scalar parameters and a binarized mask adapt the pretrained kernel.

The "Simple" Transformation

Through empirical testing, the researchers discovered that a "Simple" version of this transformation, which omits the multiplicative term ($k_3$), often performs remarkably well:

$$\check{W} = k_0W + k_1\mathbf{1} + k_2M$$

This version reduces the complexity of the transformation while still providing enough flexibility to shift the weight distribution effectively for new domains.

The "Simple" version of the weight transformation, which omits the multiplicative $k_3$ term while maintaining high performance.

To train these discrete binary masks, the authors employ a surrogate gradient approach, treating the mask as a continuous variable during the backward pass to allow for standard gradient-based optimization.

Experimental Setup and Benchmarks

The approach was evaluated on two rigorous benchmarks:

  • ImageNet-to-Sketch: This includes six datasets ranging from fine-grained categories (CUBS Birds, Stanford Cars) to stylistically distinct domains like WikiArt and Sketches.
  • Visual Decathlon Challenge: A benchmark of 10 diverse datasets, including satellite imagery, textures, and handwritten characters (Omniglot, SVHN, CIFAR-100).

Key Insights and Results

  • Flexibility and Expressiveness: The addition of a shift ($k_1$) and a mask-based bias ($k_2$) allows the model to do more than just toggle weights. It can actively reshape the feature space for the new task. This leads to denser masks compared to previous methods, as the model can repurpose more of the original network's knowledge.
  • State-of-the-Art Performance: The "Full" model achieved a score of 3497 on the Visual Decathlon, significantly surpassing the previous state-of-the-art of 2852. On the ImageNet-to-Sketch benchmark, the method closed the gap with individually fine-tuned models, often reaching within 1% of their accuracy.
  • Extreme Efficiency: The method is incredibly lightweight, requiring only slightly more than 1 bit per parameter per task. For a ResNet-50 architecture, adding five new tasks increases the total parameter count by only 17%, compared to the 500% increase required by traditional fine-tuning.
  • Task-Specific Batch Normalization: A critical finding was the importance of maintaining task-specific statistics for Batch Normalization layers, which allows the network to normalize features appropriately for different visual domains.

Conclusion and Future Work

This weight transformation approach provides a scalable and high-performance solution for multi-task learning. While highly effective, the authors note that results could potentially be improved with task-specific hyperparameter tuning. Future research directions include exploring "cross-task affine transformations" to allow knowledge sharing between learned tasks and investigating how this method scales to "life-long learning" scenarios involving hundreds of sequential tasks.

Summary updated

BibTeX
@inproceedings{mancini2018adding,
  author = {Massimiliano Mancini and Elisa Ricci and Barbara Caputo and Samuel Rota Bulò},
  title = {{Adding New Tasks to a Single Network with Weight Transformations Using Binary Masks}},
  booktitle = {Workshops @ ECCV},
  year = {2018},
  doi = {10.1007/978-3-030-11012-3\_14},
}
Figure