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

Compositional Models: Multi-Task Learning and Knowledge Transfer with Modular Networks

Andrey Zhmoginov, Dina Bashkirova, Mark Sandler

Abstract

Conditional computation and modular networks have been recently proposed for multitask learning and other problems as a way to decompose problem solving into multiple reusable computational blocks. We propose a new approach for learning modular networks based on the isometric version of ResNet with all residual blocks having the same configuration and the same number of parameters. This architectural choice allows adding, removing and changing the order of residual blocks. In our method, the modules can be invoked repeatedly and allow knowledge transfer to novel tasks by adjusting the order of computation. This allows soft weight sharing between tasks with only a small increase in the number of parameters. We show that our method leads to interpretable self-organization of modules in case of multi-task learning, transfer learning and domain adaptation while achieving competitive results on those tasks.

Introduction

In traditional deep learning, neural networks are typically designed as monolithic, rigid stacks of layers. Each layer is specialized for a specific stage of feature extraction—early layers for edges, middle layers for textures, and late layers for complex objects. While effective, this architecture is inherently inefficient for multi-task learning and knowledge transfer. Reusing a specific capability (like texture processing) across different tasks usually requires duplicating parameters or complex, often unstable, routing mechanisms.

This paper introduces a framework where a model is treated as a "mixture" of shared modules that can self-organize to solve multiple problems. By moving away from fixed sequences to a "template bank" of reusable blocks, the authors enable models to grow in depth and adapt to new domains with minimal parameter overhead.

The Modular Approach: Isometric Backbones and Template Banks

The proposed compositional model relies on two key architectural innovations: the isometric backbone and the parameter mixture mechanism.

1. Isometric Backbone

To ensure that modules are interchangeable, the authors utilize an Isometric ResNet. In this architecture, every residual block maintains the same input and output dimensions and internal configuration. Because the data representation "shape" remains constant across the network, any block from the template bank can theoretically be placed at any position in the sequence.

2. The Template Bank

Instead of training a fixed sequence of $L$ layers, the model maintains a bank of $K$ "template" blocks. For each layer in the network, the actual parameters are computed as a linear combination of these templates, governed by task-specific mixture weights ($\xi$).

Comparison between conventional weight sharing and the proposed compositional model using a template bank.

This approach allows for "soft weight sharing." During training, a clustering regularizer encourages these weights to become "one-hot," effectively forcing the network to select the single most appropriate template for each layer position. This differentiability avoids the instability common in discrete routing methods based on reinforcement learning.

Interpretable Self-Organization

One of the most compelling aspects of this modular approach is how the network self-organizes across different tasks and domains.

  • Multi-Task Learning: When trained on multiple datasets (e.g., ImageNet, Places365, SUN397), the model naturally learns to share early layers, which handle low-level feature extraction common to all natural images. However, it diverges in the later layers, selecting unique templates to handle task-specific classification requirements.
  • Domain Adaptation: In scenarios where the labels are the same but the input domains differ (e.g., photos vs. sketches), the model does the opposite: it uses unique templates in the initial layers to "normalize" the domain-specific input styles and shares the later layers for the actual classification logic.
Heatmaps showing the learned assignment of layers to specific templates across different datasets, illustrating the self-organization of the modular network.

Key Results and Scaling

The modular framework demonstrates significant advantages in both accuracy and parameter efficiency:

  • Depth for Free: Because templates can be reused, a model's computational depth can be increased without adding new parameters. For instance, by "unrolling" an 8-layer isometric model into a 32-layer modular version, ImageNet accuracy improved from 68.3% to 70.6% with zero increase in the total parameter count stored on disk.
  • Extreme Parameter Efficiency: In domain adaptation tasks, the authors achieved competitive performance by tuning only the mixture weights—approximately 100 parameters—whereas standard fine-tuning methods require updating millions.
  • Multi-Task Performance: The compositional model consistently achieved lower cross-entropy loss across five simultaneous tasks compared to standard "hard" weight-sharing baselines, proving that flexible modularity outperforms rigid sharing.

Conclusion

The transition from monolithic to compositional architectures represents a significant step toward more flexible and interpretable neural networks. By treating layers as reusable templates, this method provides a path toward "fluid" architectures that can adapt their internal structure to the task at hand, enabling better transfer learning and more efficient use of computational resources.

Summary updated

BibTeX
@misc{zhmoginov2021compositional,
  author = {Andrey Zhmoginov and Dina Bashkirova and Mark Sandler},
  title = {{Compositional Models: Multi-Task Learning and Knowledge Transfer with Modular Networks}},
  year = {2021},
  eprint = {2107.10963},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.10963},
}
Figure