Learning Sparse Neural Networks through L_0 Regularization

Christos Louizos, Max Welling, Diederik P. Kingma

TL;DR

This paper introduces a practical way to perform $L_0$ regularization—penalizing the exact number of non-zero weights—directly within stochastic gradient descent (SGD). By using a novel "hard concrete" distribution to create stochastic gates, the authors make the discrete act of pruning weights differentiable. This allows neural networks to prune themselves during training, leading to better computational efficiency and generalization.

The Problem: Over-parametrization and the $L_0$ Nightmare

Deep neural networks are notoriously over-parametrized. While this massive capacity helps them learn complex patterns, it leads to two major issues:

  1. Efficiency: Large models require massive computation and memory, much of which is wasted on "dead" weights that don't meaningfully contribute to the output.
  2. Generalization: Over-parametrized models are prone to overfitting, essentially memorizing noise in the training data rather than learning robust features.

The theoretically ideal solution is $L_0$ regularization, which adds a penalty strictly proportional to the number of non-zero parameters. Unlike $L_1$ regularization (Lasso), which shrinks all weight values and can harm model performance, $L_0$ is the "true" measure of sparsity. It only cares whether a weight is zero or not; if it's non-zero, it can be as large as it needs to be.

However, $L_0$ is a discrete, combinatorial nightmare. Because it is non-differentiable, you cannot use standard backpropagation to optimize it. Consequently, most existing pruning methods require training a full model first and then pruning it in a separate, computationally expensive post-processing step.

Methods: Differentiable Pruning via Stochastic Gates

The authors propose a framework to make the expected $L_0$ norm differentiable using stochastic gates.

1. The Stochastic Gate

Every weight $\theta$ in the network is multiplied by a gate $z \in \{0, 1\}$. If $z=0$, the weight is pruned. To make this compatible with SGD, the authors treat $z$ as a random variable. The $L_0$ penalty then smoothly becomes the sum of the probabilities that each gate is "on."

2. The Hard Concrete Distribution

The core innovation of the paper is the Hard Concrete distribution. Standard continuous relaxations (like the Concrete or Gumbel-Softmax distributions) stay strictly between 0 and 1. This means weights are never exactly zero during training, defeating the purpose of true $L_0$ sparsity.

The authors fix this with a clever three-step "stretch-and-fold" trick:

  • Stretch: They take a binary concrete distribution and stretch its range from $(0, 1)$ to a wider interval $(\gamma, \zeta)$, where $\gamma < 0$ and $\zeta > 1$.
  • Clip (Hard-Sigmoid): They pass the samples through a hard-sigmoid function: $z = \min(1, \max(0, s))$.
  • Fold: Because the distribution was stretched, any sample that falls in the $(\gamma, 0]$ range is "folded" into an exact 0, and any sample in $[1, \zeta)$ is folded into an exact 1.
Probability density of the concrete vs. hard concrete distribution.

As shown above, this creates a distribution with "spikes" of probability mass at exactly 0 and 1 (indicated by the vertical arrows), while remaining differentiable in the middle. The parameters of this distribution can then be optimized via the reparameterization trick.

3. Group Sparsity

The method easily extends to Group Sparsity. By sharing a single stochastic gate across an entire neuron or a convolutional feature map, the model can prune entire structural units. This leads to actual hardware speedups rather than just theoretical, unstructured sparsity.

Key Results and Insights

The authors evaluated their method on standard computer vision benchmarks, including MNIST (using MLPs and LeNet-5) and CIFAR-10/100 (using Wide Residual Networks).

  • Competitive Sparsity: On MNIST, the method pruned LeNet-5 down to a tiny fraction of its original size—for example, reducing 800 neurons in a layer down to approximately 45—while maintaining a highly competitive ~0.9% error rate.
  • Outperforming Dropout: On CIFAR-10, the $L_0$ regularized Wide ResNet achieved 3.83% error, outperforming the standard dropout baseline (3.89%) while being significantly more parameter-efficient.
  • Training-Time Speedups: Because the model prunes itself during training, the computational cost actively decreases.
Expected FLOPs during training.

The authors demonstrated a clear downward trajectory of expected Floating Point Operations (FLOPs) during training. As the network learns which weights are unnecessary, the $L_0$ penalty forces those gates to zero, dynamically reducing the computational load epoch by epoch.

Limitations and Future Work

  • Gradient Variance: The method relies on Monte Carlo sampling of the gates. Using only a single sample per minibatch can introduce noise and variance into the gradients, though the authors found this manageable in practice.
  • Hyperparameter Sensitivity: The sparsity-accuracy trade-off is controlled by the penalty weight $\lambda$. Finding the "sweet spot" for $\lambda$ might require tuning depending on the specific architecture and dataset.
  • Bayesian Extension: The authors suggest that combining this approach with a full Bayesian treatment—modeling uncertainty over the weights themselves, not just the gates—could further improve results and robustness.

Summary updated

BibTeX
@inproceedings{louizos2018learning,
  author = {Christos Louizos and Max Welling and Diederik P. Kingma},
  title = {{Learning Sparse Neural Networks through L\_0 Regularization}},
  booktitle = {International Conference on Learning Representations},
  year = {2018},
  url = {https://openreview.net/forum?id=H1Y8hhg0b},
}
Figure