Learning Activation Functions for Sparse Neural Networks

Mohammad Loni, Aditya Mohan, Mehdi Asadi, Marius Lindauer

Abstract

Sparse Neural Networks (SNNs) offer a path toward energy-efficient and memory-light inference by removing redundant weights. However, at high pruning ratios, these networks often suffer from significant accuracy degradation. This research identifies two primary culprits: the ubiquitous use of the ReLU activation function and the reliance on hyperparameters tuned for dense models. We introduce Sparse Activation Function Search (SAFS), a framework that learns layer-specific activation functions and sparsity-aware hyperparameters. Our experiments across models like LeNet-5, VGG-16, and ResNet-18 demonstrate absolute accuracy improvements of up to 15.53%, 8.88%, and 6.33% respectively, particularly in extreme sparsity regimes.

The Challenge of Sparsity

While network pruning is a standard technique for deploying Deep Neural Networks (DNNs) on edge devices, the "dense-first" defaults often fail in sparse landscapes. The authors identify two underexplored reasons for this decline:

  1. The ReLU Trap: ReLU is the default choice for most architectures. In sparse networks, its sudden gradient changes at zero can stifle gradient flow through the limited remaining connections, hindering trainability.
  2. Hyperparameter Mismatch: Researchers typically fine-tune sparse networks using the same learning rates and schedulers designed for their original dense counterparts. Sparse loss landscapes are fundamentally different and require a distinct optimization regime.

Sparse Activation Function Search (SAFS)

The SAFS framework addresses these issues through a two-stage optimization pipeline designed to "re-tune" a network after it has been pruned.

Instead of a fixed activation function, SAFS searches for the optimal "type" (e.g., Swish, Tanh, ELU) for each individual layer. This discrete search space is navigated using Late Acceptance Hill Climbing (LAHC), an algorithm capable of escaping local optima by occasionally accepting inferior solutions.

The SAFS approach uses a parametric activation function and searches for the best function type per layer.

2. Scaling Factors and Hyperparameter Optimization (HPO)

Once the function types are established, they are treated as parametric functions: $y = \alpha f(\beta x)$. SAFS then jointly optimizes the scaling factors ($\alpha, \beta$) and standard training hyperparameters (learning rate, optimizer type, etc.) using SMAC3, a Bayesian optimization tool.

The SAFS pipeline integrates pruning, unary operator search, and hyperparameter optimization to recover accuracy.

Experimental Results

The framework was evaluated on MNIST (LeNet-5), CIFAR-10 (VGG-16, ResNet-18), and ImageNet-16 (ResNet-18, EfficientNet-B0). The most significant gains were observed at extreme sparsity (99% pruning ratio):

  • LeNet-5: 15.53% absolute improvement over default training protocols.
  • VGG-16: 8.88% improvement, reaching 79.2% accuracy compared to the 70.32% baseline.
  • ResNet-18: 6.33% improvement on CIFAR-10.

Key Insights

  • Beyond ReLU: At 99% sparsity, functions like Symlog and Acon frequently outperformed ReLU, especially in early layers.
  • Improved Gradient Flow: Visualization of gradient flow reveals that SAFS-trained networks maintain higher and more stable gradient values throughout training, explaining their superior recovery.
  • Layer Heterogeneity: Different layers benefit from different functions; for instance, VGG-16 often utilizes Swish in middle layers and Acon in early layers.

Conclusion and Future Work

SAFS demonstrates that activation functions and hyperparameters are critical, yet often overlooked, factors in the performance of sparse neural networks. While the current search process is computationally intensive (e.g., 47 GPU hours for VGG-16), future work focusing on efficiency—such as using accuracy predictors—could make this framework a standard part of the pruning pipeline.

Summary updated

BibTeX
@inproceedings{loni2023learning,
  author = {Mohammad Loni and Aditya Mohan and Mehdi Asadi and Marius Lindauer},
  title = {{Learning Activation Functions for Sparse Neural Networks}},
  booktitle = {AutoML},
  year = {2023},
  url = {https://openreview.net/forum?id=jftC1eyySg},
}
Figure