Deriving Activation Functions via Integration

Imanol Schlag, Allen Hao HuangarXiv 2024 · DOI

Introduction

In the pursuit of more efficient and expressive neural networks, researchers have introduced a "gradient-first" approach to designing activation functions. Rather than selecting a function and evaluating its derivative, this method involves defining desired gradient properties and integrating them to derive the activation function. The primary result of this approach is xIELU, a trainable activation function that combines the strengths of industry standards like SwiGLU and ReLU² while mitigating their inherent weaknesses.

The Gradient Gap in Modern Architectures

Activation functions introduce the non-linearity essential for learning complex patterns. However, current standards present significant trade-offs:

  • ReLU and ReLU²: While computationally efficient, they suffer from the "dying ReLU" problem, where negative inputs result in zero gradients, effectively halting the learning process for those neurons.
  • GELU and SiLU (Swish): These functions provide non-zero gradients for negative inputs, aiding recovery. However, their gradients for positive inputs are "bounded," typically flatlining at 1.0, which can restrict a model's ability to learn from high-magnitude activation signals.

The authors identified a critical gap: no single standard function offered both the unbounded, linearly increasing gradient of ReLU² (beneficial for positive signals) and the negative-valued gradients of GELU/SiLU (beneficial for expressivity and recovery).

Comparison of standard activation functions and their derivatives, highlighting the differences in gradient behavior.

Methods: From Gradient to Function

The proposed design workflow follows a three-step process: Design the Gradient $\rightarrow$ Integrate $\rightarrow$ Derive the Function. Using this framework, the authors introduced two primary functions:

  1. xIELU (Expanded Integral of the Exponential Linear Unit): Derived by integrating an affine transformation of the ELU function. It features a quadratic curve for positive values and an exponential curve for negative values.
  2. xIPReLU (Expanded Integral of PReLU): A computationally leaner version that utilizes a linear curve for negative inputs instead of an exponential one.

Adaptive Nonlinearity

A key innovation is that these functions are trainable. They incorporate scalar parameters ($\alpha_p$ and $\alpha_n$) that are learned independently for every layer, allowing the network to dynamically shape its activation functions. To maintain numerical stability, the authors employ a softplus constraint on these parameters and use torch.expm1() to prevent precision errors.

The xIELU function and its gradient for negative inputs, demonstrating how the trainable parameter alpha_n allows for flexible, negative-valued gradients.

Experimental Evaluation

The authors evaluated xIELU using Large Language Models (LLMs) based on the Llama architecture, ranging from 1.1B to 3B parameters. The models were pre-trained on 125B tokens of FineWeb Edu and tested across a diverse suite of benchmarks, including PIQA, ARC, MMLU, and GSM8k.

Key Results

  • Superior Perplexity: In the 1.1B parameter model, xIELU achieved a perplexity of 10.21, significantly outperforming SwiGLU (10.52) and ReLU² (10.35) at comparable compute costs. This advantage persisted at the 3B parameter scale.
  • Task Performance: While SwiGLU remains competitive in linguistic reasoning, xIELU showed a distinct advantage in factual recall (TriviaQA) and structured reasoning (GSM8k).
  • Emergent Behavior: Interestingly, the trainable $\alpha$ parameters consistently decreased in deeper layers, suggesting that the model naturally evolves toward more linear behavior as the network depth increases.

Conclusion and Future Work

The "gradient-first" design paradigm offers a powerful new tool for neural network optimization. While xIELU demonstrates clear empirical advantages in perplexity and reasoning tasks, the authors note that production-level adoption will require custom, fused CUDA kernels to match the raw throughput of highly optimized ReLU² implementations. Future research will explore the stability of these higher-order functions in low-precision environments like FP8 and seek a deeper theoretical understanding of why specific gradient shapes, such as the negative turning point, are so effective.

Summary updated

BibTeX
@misc{schlag2024deriving,
  author = {Imanol Schlag and Allen Hao Huang},
  title = {{Deriving Activation Functions via Integration}},
  year = {2024},
  eprint = {2411.13010},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.13010},
}
Figure