Introduction
In the field of deep learning, the Rectified Linear Unit (ReLU) has long been the standard activation function due to its simplicity and computational efficiency. However, as neural architectures evolve toward complex structures like Vision Transformers (ViTs) and Large Language Models (LLMs), a universal nonlinearity may no longer be optimal. While alternatives like Swish (SiLU) or GELU offer performance improvements, manually designing these functions is a difficult task, and previous automated search methods—often based on reinforcement learning or evolutionary algorithms—require thousands of full model evaluations. This paper introduces GRAFS (GRadient-based Activation Function Search), an efficient optimization-based approach to discover model-specific activation functions at a fraction of the traditional computational cost.
Methodology: The GRAFS Framework
GRAFS treats the activation function as a small "computational cell" composed of basic mathematical building blocks. The search space is defined by a tree structure containing unary and binary operations, allowing for the discovery of complex nonlinearities.
The framework employs gradient-based optimization via continuous relaxation. Instead of selecting a single function, the search space is relaxed into a weighted sum of all possible operations. Weights are assigned to each unary operation (such as $x^2$, $\sin(x)$, or $\text{erf}(x)$) and binary operation (such as addition or multiplication). Gradient descent is then used to identify the most effective combinations through a bi-level optimization loop: the outer loop optimizes the activation function parameters, while the inner loop trains the network weights. To ensure stability and prevent gradient explosion, the authors implemented warmstarting with standard activations, output clipping (constrained to $\pm 10$), and progressive shrinking, which gradually removes low-performing operations until a single "winner" remains.
Experimental Setup and Datasets
The team evaluated GRAFS across two major domains to test its versatility:
- Computer Vision: Benchmarked on CIFAR-10, CIFAR-100, and SVHN Core using ResNet and ViT architectures.
- Language Modeling: Evaluated on the TinyStories dataset using miniGPT models to test performance in transformer-based architectures.
Results and Discussion
GRAFS demonstrates remarkable efficiency, finding superior activations in the time required for only 0.2 to 4 full model trainings. This is orders of magnitude faster than previous state-of-the-art methods that required over 10,000 evaluations, making custom activation search a practical "plug-and-play" step for any new architecture.
Key findings from the experiments include:
- Performance Gains: Discovered activations consistently outperformed ReLU, SiLU, and GELU. For example, on CIFAR-10 with ResNet20, the discovered function $F^4_{RN}$ achieved a top-1 accuracy of 92.148%, surpassing the ReLU baseline of 91.81%.
- Transferability: Activations found on smaller proxy models (e.g., ResNet20) transferred effectively to larger architectures (e.g., ResNet32) and different datasets like SVHN. This suggests that optimal nonlinearities are largely architecture-dependent rather than data-dependent.
- Validation of Prior Research: In language modeling tasks using miniGPT, the search converged on functions involving $x^2$. This independently validates the effectiveness of squared ReLUs in Transformers, a finding previously highlighted in the "Primer" paper (So et al., 2021).
Conclusion
GRAFS provides a practical and efficient method for optimizing activation functions for specific neural architectures. While the resulting functions may be more computationally complex than a simple ReLU, the performance improvements and search efficiency make GRAFS a valuable tool for modern deep learning practitioners. Future work may explore more complex tree structures and joint searches where different layers of a network utilize distinct activation functions.
Summary updated