Abstract
The choice of activation functions is crucial for modern deep neural networks. Popular hand-designed activation functions like Rectified Linear Unit (ReLU) and its variants show promising performance in various tasks and models. Swish, the automatically discovered activation function, has been proposed and outperforms ReLU on many challenging datasets. However, it has two main drawbacks. First, the tree-based search space is highly discrete and restricted, which is difficult for searching. Second, the sample-based searching method is inefficient, making it infeasible to find specialized activation functions for each dataset or neural architecture. To tackle these drawbacks, we propose a new activation function called Piecewise Linear Unit (PWLU), which incorporates a carefully designed formulation and learning method. It can learn specialized activation functions and achieves SOTA performance on large-scale datasets like ImageNet and COCO. For example, on ImageNet classification dataset, PWLU improves 0.9%/0.53%/1.0%/1.7%/1.0% top-1 accuracy over Swish for ResNet-18/ResNet-50/MobileNet-V2/MobileNet-V3/EfficientNet-B0. PWLU is also easy to implement and efficient at inference, which can be widely applied in real-world applications.
1. Introduction
Activation functions serve as the fundamental non-linear components of neural networks, determining the flow of information across layers. While the Rectified Linear Unit (ReLU) has become the industry standard due to its simplicity, it offers a fixed, non-adaptive response. Recent alternatives like Swish, discovered through automated search, provide performance gains but are computationally expensive to find and produce static functions that may not be optimal for every layer or architecture.
We identify two primary challenges in developing specialized activations: search inefficiency and input-boundary misalignment. The latter occurs when a learnable activation's flexible region does not align with the actual distribution of data passing through it, rendering the learning process ineffective. To address these, we introduce the Piecewise Linear Unit (PWLU), a learnable activation function that adapts its shape to specific architectures and datasets using standard gradient descent.
2. Methods
The PWLU is formulated as a continuous function composed of $N$ connected linear segments. It is defined by learnable parameters including boundaries ($B_L, B_R$) that define the flexible range, Y-axis values ($Y_P$) at segment connection points, and slopes ($K_L, K_R$) for regions outside the main boundaries.
Statistic-based Realignment
To overcome the misalignment problem, we propose a two-phase training strategy. In Phase I, the PWLU is initialized to mimic a ReLU. During these initial iterations, the model collects the mean ($\mu$) and standard deviation ($\sigma$) of inputs for every activation layer without updating the PWLU parameters. In Phase II, the boundaries are reset based on the 3-sigma rule ($B_L = \mu - 3\sigma, B_R = \mu + 3\sigma$), ensuring the flexible segments are centered where the data resides. Only after this realignment does the model begin learning the optimal activation shape via backpropagation.
3. Results and Discussion
PWLU was evaluated on large-scale benchmarks including ImageNet and COCO across five diverse architectures. The results demonstrate that PWLU consistently outperforms both ReLU and Swish. On ImageNet, PWLU improved Top-1 accuracy by 0.9% on ResNet-18 and 1.7% on MobileNet-V3 compared to Swish. For object detection on COCO using Mask R-CNN, PWLU achieved 40.48% AP, surpassing both ReLU (39.06%) and Swish (40.05%).
Beyond accuracy, PWLU is highly efficient. At inference time, the piecewise calculation collapses into a single multiply-add operation ($x * S_{idx} + O_{idx}$), making it nearly as fast as ReLU. Visualizations of learned functions show that PWLU often evolves into specialized "V-shapes" or nearly linear forms in early layers, highlighting that different architectures and layers require unique activation shapes to maximize expressiveness.
4. Conclusion
The Piecewise Linear Unit offers a robust, learnable alternative to fixed activation functions. By aligning its flexible regions with data statistics, PWLU achieves state-of-the-art performance while maintaining inference efficiency. While less effective in modules with extremely small feature maps like Squeeze-and-Excitation blocks, PWLU represents a significant advancement in adaptive neural network design. Future research will explore contextual-based PWLU, where activation parameters dynamically change based on the input features themselves.
Summary updated