A Method on Searching Better Activation Functions

Haoyuan Sun, Zihao Wu, Bo Xia, Pu Chang, Zibin Dong, Yifu Yuan, Yongzhe Chang, Xueqian Wang

TL;DR

This paper moves beyond the empirical "trial-and-error" approach to designing activation functions by introducing a theoretical framework based on information entropy. The authors prove the existence of a "worst" activation function and propose the Entropy-based Activation Function Optimization (EAFO) methodology to systematically improve existing ones, leading to the creation of CRReLU, a new activation function that outperforms GELU and ReLU across vision and language tasks.

What Problem Does This Paper Address?

Activation functions (AFs) are the heartbeat of non-linearity in neural networks, yet their discovery has historically been more of an art than a science. While functions like ReLU, GELU, and Swish are industry standards, they were largely identified through empirical observation rather than rigorous theoretical derivation.

The authors argue that this lack of a theoretical framework makes the search for better AFs "inefficient and aimless." Specifically, they target the gap between information theory (how data is represented) and the functional form of the activation function, seeking a way to mathematically justify why one function performs better than another.

Methods

The researchers approach the problem through the lens of Information Entropy. They posit that a better activation function should minimize the information entropy of the data distribution it produces, thereby reducing classification uncertainty (the Bayesian error rate).

Key steps in their methodology include:

  1. Defining the "Worst" Case: Using the Euler-Lagrange equation, they theoretically derive the Worst Activation Function with Boundary Conditions (WAFBC)—the function that maximizes entropy. Interestingly, these "worst" functions often resemble bounded functions like Sigmoid or Tanh.
  2. EAFO Methodology: Inspired by the Taylor expansion of the information entropy functional, they propose a method to calculate a "correction term" $\eta(x)$ that, when added to an existing function, is guaranteed to decrease its entropy.
  3. Deriving CRReLU: By applying EAFO to the standard ReLU and assuming a Gaussian data distribution (supported by the Central Limit Theorem for large networks), they derive the Correction Regularized ReLU (CRReLU): $$f(x) = \max(0, x) + \epsilon x e^{-x^2/2}$$ Here, $\epsilon$ is a small learnable parameter that allows the network to self-optimize its non-linearity during training.

Datasets

The authors validated CRReLU across several standard benchmarks:

  • Image Classification: CIFAR-10, CIFAR-100, and ImageNet-1K.
  • LLM Fine-tuning: The Stanford Human Preferences (SHP) and Anthropic Helpful and Harmless (HH) datasets were used for Direct Preference Optimization (DPO) tasks.

Key Insights and Ideas

  • The Boundedness Trap: The proof of the WAFBC provides a theoretical explanation for why unbounded functions like ReLU often outperform bounded ones like Sigmoid: bounded functions are mathematically closer to the "maximum entropy" (worst) state.
  • Beyond Dying ReLU: CRReLU introduces a non-zero gradient for negative values, helping to mitigate the "dying ReLU" problem. However, unlike Leaky ReLU, it converges back to zero as $x \to -\infty$, preserving model sparsity.
  • Learnable Non-linearity: By treating the correction strength $\epsilon$ as a learnable parameter, the authors allow the model to adapt its activation behavior to the specific data distribution it encounters, rather than relying on a static, one-size-fits-all curve.

Key Results

CRReLU demonstrated significant performance gains over established baselines like GELU, Swish, and Mish, particularly in Vision Transformer (ViT) architectures.

  • CIFAR-100: On ViT-Tiny, CRReLU achieved a top-one accuracy of 0.459, a massive jump compared to GELU's 0.322. Table 2: Test accuracy of experiments conducted on CIFAR-100 for 100 epochs.
Table 2: Test accuracy of experiments conducted on CIFAR-100 for 100 epochs.
  • ImageNet-1K: CRReLU maintained its lead on larger datasets, outperforming GELU on ViT-Tiny (0.579 vs 0.542). Table 3: Test accuracy of experiments conducted on ImageNet-1K for 100 epochs.
Table 3: Test accuracy of experiments conducted on ImageNet-1K for 100 epochs.
  • CIFAR-10: The trend continued here, with CRReLU reaching 0.802 accuracy on ViT-Tiny, significantly higher than GELU's 0.706. Table 1: Test accuracy of experiments conducted on CIFAR-10 for 100 epochs.
Table 1: Test accuracy of experiments conducted on CIFAR-10 for 100 epochs.

In LLM fine-tuning (GPT-2), CRReLU consistently outperformed GELU across margin rewards and loss metrics, suggesting it generalizes well to language tasks.

Limitations and Future Work

While promising, the authors note several areas for further exploration:

  • Invertibility Constraints: The current EAFO framework is most straightforward for invertible functions. Generalizing it to non-invertible functions requires heuristic approximations.
  • Computational Complexity: While static CRReLU is efficient, the potential for dynamic optimization of activation functions during every training iteration currently faces high computational overhead.
  • Architectural Breadth: The authors suggest testing EAFO on alternative structures like Kolmogorov-Arnold Networks (KANs) to see if the entropy-based approach holds across different paradigms of connectivity.

Summary updated

BibTeX
@inproceedings{sun2024method,
  author = {Haoyuan Sun and Zihao Wu and Bo Xia and Pu Chang and Zibin Dong and Yifu Yuan and Yongzhe Chang and Xueqian Wang},
  title = {{A Method on Searching Better Activation Functions}},
  booktitle = {SciForDL @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=tLtf4lRz0l},
}
Figure