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

Learning the Number of Neurons in Deep Networks

Jose M. Alvarez, Mathieu Salzmann

TL;DR

This paper tackles the "dark art" of deep learning architecture design by introducing a method to automatically determine the optimal number of neurons in each layer during training. By applying a group sparsity regularizer that treats all parameters of a single neuron as a group, the authors successfully shrink networks by up to 80% while maintaining, or even improving, classification accuracy.

The Problem: Guesswork in Architecture Design

Designing a deep neural network usually involves a significant amount of guesswork. Engineers typically set the number of layers and neurons per layer manually through trial and error. While "over-parameterized" (very wide and deep) networks perform well, they are computationally expensive and memory-intensive, making them difficult to deploy on mobile or embedded devices.

Existing solutions usually involve "pruning" a network after it has been trained. This is a multi-step process that often requires calculating complex second-order derivatives (like the Hessian matrix). The authors sought a "one-step" approach: a way to learn the network's weights and its optimal width simultaneously, without the need for expensive post-processing.

Methodology: Group Sparsity

The core idea is to use Group Sparsity as a regularizer during the training process.

  1. Grouping by Neuron: In a standard network, a single neuron is defined by a set of weights and a bias. The authors define each of these sets as a "group."
  2. The Regularizer: They employ a Sparse Group Lasso penalty. Unlike standard $L_2$ regularization (weight decay), which just makes weights small, or $L_1$ regularization, which zeroes out individual weights, group sparsity encourages the entire group of weights for a neuron to go to zero.
  3. Proximal Gradient Descent: Because these sparsity-inducing regularizers are non-differentiable at zero, the authors use proximal gradient descent. This allows the optimization algorithm to "snap" entire groups of parameters to exactly zero during training.
  4. Automatic Pruning: Once training is finished, any neuron whose parameters are all zero is simply deleted. In fully connected layers, this creates a ripple effect: if a neuron in layer $L$ is removed, the corresponding inputs to layer $L+1$ also disappear, further compacting the model.
Neuron reduction across layers in BNet

Key Insights

  • Simultaneous Learning: Unlike traditional pruning, which is a "destructive" post-processing step, this method performs model selection during learning. You don't need a perfectly trained large model to start; you just need an overcomplete one.
  • The Generalization Bonus: Surprisingly, reducing the number of neurons often increased accuracy. By removing redundant parameters, the regularizer acts as a powerful tool against overfitting, narrowing the gap between training and validation performance.
  • Per-Layer Weighting: The authors found it most effective to use different regularization strengths for different layers—specifically, smaller weights for the first few layers to preserve low-level features and larger weights for deeper layers where redundancy is higher.
  • Efficiency at Test Time: The method doesn't just result in fewer parameters; it leads to actual wall-clock speedups (up to 50%) because the resulting architecture is physically smaller.

Key Results

The authors evaluated their approach on three diverse datasets: ImageNet (ILSVRC-2012), Places2-401, and ICDAR.

  • Parameter Reduction: On the ICDAR dataset, the method reduced the number of parameters by 80% while actually improving accuracy compared to the baseline.
  • ImageNet Performance: For the VGG-style "BNet" architecture, the method removed about 12.7% of neurons, leading to a 27.38% reduction in total induced parameters and a 1.6% increase in Top-1 accuracy.
Compression and accuracy gains for BNet on ImageNet
  • Speed and Memory:
    • Speedup: The reduced models achieved up to a 13% speedup on ImageNet and nearly 50% speedup on ICDAR.
  • Memory: Memory savings for parameters reached up to 82% for the most compressed models.

Limitations and Future Work

  • Fixed Depth: While the method automatically decides how wide each layer should be (number of neurons), the number of layers (depth) remains fixed. The authors suggest that future work could involve "bypass" mechanisms to allow the model to skip entire layers, effectively learning the depth as well.
  • Hyperparameter Sensitivity: The method introduces new hyperparameters (controlling the strength of the sparsity). While the authors provide heuristics for these, they still require some tuning.
  • Scope: The paper focuses primarily on classification. Evaluating this approach on regression tasks or autoencoders is a logical next step.

Summary updated

BibTeX
@inproceedings{alvarez2016learning,
  author = {Jose M. Alvarez and Mathieu Salzmann},
  title = {{Learning the Number of Neurons in Deep Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2016},
  url = {https://openreview.net/forum?id=HJWI_dbOWr},
}
Figure