MaskConnect: Connectivity Learning by Gradient Descent

Karim Ahmed, Lorenzo Torresani

Abstract

Although deep networks have recently emerged as the model of choice for many computer vision problems, in order to yield good results they often require time-consuming architecture search. To combat the complexity of design choices, prior work has adopted the principle of modularized design which consists in defining the network in terms of a composition of topologically identical or similar building blocks (a.k.a. modules). This reduces architecture search to the problem of determining the number of modules to compose and how to connect such modules. Again, for reasons of design complexity and training cost, previous approaches have relied on simple rules of connectivity, e.g., connecting each module to only the immediately preceding module or perhaps to all of the previous ones. Such simple connectivity rules are unlikely to yield the optimal architecture for the given problem. In this work we remove these predefined choices and propose an algorithm to learn the connections between modules in the network. Instead of being chosen a priori by the human designer, the connectivity is learned simultaneously with the weights of the network by optimizing the loss function of the end task using a modified version of gradient descent. We demonstrate our connectivity learning method on the problem of multi-class image classification using two popular architectures: ResNet and ResNeXt. Experiments on four different datasets show that connectivity learning using our approach yields consistently higher accuracy compared to relying on traditional predefined rules of connectivity. Furthermore, in certain settings it leads to significant savings in number of parameters.

Introduction

Designing deep neural networks is a complex task that traditionally requires significant human expertise. While modular designs—such as ResNet (sequential stacking) or ResNeXt (parallel branching)—have simplified the process, the "wiring" between these blocks remains largely hand-coded. Designers typically rely on rigid rules, such as connecting a block only to its immediate predecessor or to every previous block (as seen in DenseNet).

These predefined connectivity rules are unlikely to be optimal for every dataset. However, searching for the perfect architecture via Neural Architecture Search (NAS) is often computationally prohibitive, requiring thousands of GPU hours. MaskConnect addresses this by learning optimal connectivity efficiently using the same gradient descent process used to learn network weights.

Methodology

The core of the approach is the introduction of Masked Architectures. In this framework, the input to any given module is a weighted sum of outputs from previous modules, controlled by a binary mask vector ($m$).

Figure 1: (a) Illustration of connectivity learning in a sequential architecture (ResNet). (b) Connectivity learning applied to a multi-branch architecture (ResNeXt).

Key components of the MaskConnect algorithm include:

  • Joint Optimization: The network learns the convolutional weights ($\theta$) and the connectivity masks ($m$) simultaneously.
  • Stochastic Binarization: To handle the non-differentiable nature of binary switches, the authors maintain real-valued masks during training. During the forward pass, these values are treated as a multinomial distribution to sample $K$ connections (the "fan-in").
  • Gradient-Based Updates: During the backward pass, gradients are calculated for the masks, allowing the network to strengthen useful connections and weaken detrimental ones.
  • Post-Training Pruning: Once training is complete, masks are frozen to the top-$K$ values. Modules that the network deems unnecessary (those with no active outgoing connections) are pruned, resulting in a leaner model for inference.

Experimental Setup

The authors evaluated MaskConnect across four standard image categorization benchmarks:

  • CIFAR-10 & CIFAR-100: Small-scale datasets for rapid prototyping.
  • Mini-ImageNet: A subset used to test generalization.
  • ImageNet (ILSVRC 2012): The large-scale benchmark containing 1.28 million training images across 1,000 classes.

Key Insights and Results

Connectivity and Efficiency

The researchers found that the "fan-in" ($K$)—the number of previous modules each block connects to—is a critical hyperparameter. MaskConnect identifies a "sweet spot" for connectivity that hand-designed rules often miss. Furthermore, the performance gains are not merely due to increased connectivity; models with learned connectivity significantly outperformed those with the same number of randomly assigned connections.

Performance Metrics

  • Accuracy Gains: On ImageNet, a ResNet-50 style architecture using MaskConnect achieved a top-1 accuracy of 78.09%, a nearly 2% absolute improvement over the standard fixed-connectivity version (76.15%).
  • Parameter Efficiency: On CIFAR-100, MaskConnect achieved accuracy parity with state-of-the-art ResNeXt models while using 40% fewer parameters at test time (20.5M vs 34.4M) by automatically pruning unused branches.
  • Computational Overhead: Unlike RL-based NAS, MaskConnect adds only a moderate training overhead—roughly 13% to 39% extra time compared to standard training.

Conclusion

MaskConnect demonstrates that learning network connectivity via gradient descent is both feasible and highly effective. By treating architecture design as a joint optimization problem, the algorithm naturally identifies superfluous modules and optimizes information flow. Future work may explore more sophisticated aggregation schemes beyond simple addition and dynamic learning of the optimal fan-in density for each layer.

Summary updated

BibTeX
@inproceedings{ahmed2018maskconnect,
  author = {Karim Ahmed and Lorenzo Torresani},
  title = {{MaskConnect: Connectivity Learning by Gradient Descent}},
  booktitle = {European Conference on Computer Vision},
  year = {2018},
  url = {https://openreview.net/forum?id=H14GscZOWB},
}
Figure