Abstract
In seeking for sparse and efficient neural network models, many previous works investigated on enforcing L1 or L0 regularizers to encourage weight sparsity during training. The L0 regularizer measures the parameter sparsity directly and is invariant to the scaling of parameter values, but it cannot provide useful gradients, and therefore requires complex optimization techniques. The L1 regularizer is almost everywhere differentiable and can be easily optimized with gradient descent. Yet it is not scale-invariant, causing the same shrinking rate to all parameters, which is inefficient in increasing sparsity. Inspired by the Hoyer measure (the ratio between L1 and L2 norms) used in traditional compressed sensing problems, we present DeepHoyer, a set of sparsity-inducing regularizers that are both differentiable almost everywhere and scale-invariant. Our experiments show that enforcing DeepHoyer regularizers can produce even sparser neural network models than previous works, under the same accuracy level. We also show that DeepHoyer can be applied to both element-wise and structural pruning.
Introduction
Deep Neural Networks (DNNs) are notoriously resource-hungry, making them difficult to deploy on "edge" devices like smartphones or embedded sensors. Pruning—the process of turning unnecessary weights to zero—is a primary solution to reduce model size and computational complexity.
To encourage sparsity during training, researchers usually add a "regularizer" to the loss function. Historically, there have been two main choices, both with significant drawbacks. $\ell_0$ Regularization counts the number of non-zero weights; it is the "gold standard" for sparsity and is scale-invariant, but it is non-differentiable. Conversely, $\ell_1$ Regularization is differentiable and easy to use, but it is not scale-invariant, penalizing large weights just as much as small ones and often "shrinking" the entire model, which can hurt accuracy.
DeepHoyer seeks a "best of both worlds" solution: a regularizer that is differentiable like $\ell_1$ but scale-invariant and sparsity-focused like $\ell_0$.
Methodology
The core innovation is the Hoyer-Square (HS) regularizer. Inspired by the Hoyer measure used in compressed sensing, the regularizer for a weight matrix $W$ is defined as:
$$H_S(W) = \frac{(\sum |w_i|)^2}{\sum w_i^2} = \frac{\|W\|_1^2}{\|W\|_2^2}$$
Why it works:
- Differentiability: Unlike the $\ell_0$ count, this ratio is differentiable almost everywhere, allowing it to be plugged directly into standard deep learning frameworks.
- Scale Invariance: Multiplying all weights by a constant $\alpha$ leaves the ratio unchanged, preventing the shrinking bias of $\ell_1$.
- Structural Pruning (Group-HS): The authors extended this to Group-HS, applying the measure to groups of weights (e.g., filters or channels), which is crucial for hardware acceleration.
Key Insights: The Trimming Effect
Mathematically, the gradient of the HS regularizer creates a "trimming" threshold. During training, it naturally pushes small weights toward zero while protecting and maintaining the larger, more important weights. Unlike traditional pruning methods that require a manually set, fixed threshold, DeepHoyer's gradient descent path acts as a gradually adaptive threshold that evolves with the model.
Experimental Results
The authors evaluated DeepHoyer on several standard computer vision benchmarks, including MNIST (LeNet), CIFAR-10 (ResNet), and ImageNet (AlexNet, ResNet-50). DeepHoyer consistently outperformed state-of-the-art (SOTA) pruning methods:
- Extreme Sparsity: On LeNet models, DeepHoyer achieved a 38% to 63% improvement in sparsity over previous SOTA methods without sacrificing accuracy.
- AlexNet Compression: It compressed AlexNet by 21.3× (leaving only 4.69% of parameters), surpassing methods like ADMM.
- Structural Efficiency: On ResNet-50 (ImageNet), Group-HS achieved significant FLOPs reductions (e.g., 4.68×) while maintaining competitive Top-1 and Top-5 accuracy.
- ResNet Pruning: DeepHoyer successfully navigated the difficulty of pruning ResNets with skip connections, showing a better accuracy-to-FLOPs tradeoff than specialized methods like ThiNet or SFP.
Conclusion
DeepHoyer provides a mathematically elegant and practically effective approach to neural network pruning. By utilizing a differentiable, scale-invariant sparsity measure, it achieves superior compression rates and structural efficiency. While the regularizer is non-convex, empirical results show robust convergence with standard SGD. Future work may involve combining DeepHoyer with other compression techniques like quantization for even more extreme model shrinkage.
The code is publicly available at: https://github.com/yanghr/DeepHoyer
Summary updated