AI Logic

Activation Functions

Bendable Linear Units (BLU)

Updated:

Graph of BLU. At β = 0 it is a straight line (the identity function); at β = 1 it approaches −1 on the negative side and its slope approaches 2 on the positive side. β = 0.5 lies in between. All curves pass through the origin

What is BLU?

BLU (Bendable Linear Unit) is an activation function whose shape is controlled by a single parameter β\beta, ranging from the identity function, which passes the input through unchanged, to a rectifier-like shape that suppresses the negative side as ReLU does. β\beta is learned during training (Godfrey, 2019).

BLU(x)=β(x2+1−1)+x,−1≤β≤1\mathrm{BLU}(x) = \beta\left(\sqrt{x^2 + 1} - 1\right) + x, \qquad -1 \le \beta \le 1

x2+1−1\sqrt{x^2+1} - 1 is a convex U-shaped curve that equals 0 at x=0x = 0 and grows as xx moves away from 0. Because it is multiplied by β\beta and added to the line xx, a larger β\beta bends the line more strongly.

Concrete values look like this:

Input xx−2−1012
β=1\beta = 1−0.764−0.58601.4143.236
β=0.5\beta = 0.5−1.382−0.79301.2072.618
β=0\beta = 0−2−1012

How does β change the shape?

The shape changes with the value of β\beta as follows. Each property can be verified from the formula.

  • β=0\beta = 0: the identity function: The output equals the input xx.
  • β>0\beta > 0: the negative side is suppressed: At β=1\beta = 1, the output approaches −1 as xx decreases on the negative side, and the slope approaches 2 on the positive side. This is a smooth rectifier shape similar to ReLU.
  • β<0\beta < 0: a point-reflected shape: BLU−β(x)=−BLUβ(−x)\mathrm{BLU}_{-\beta}(x) = -\mathrm{BLU}_{\beta}(-x) holds, so the output on the positive side is suppressed instead.
  • Passes through the origin for every β\beta: BLU(0)=0\mathrm{BLU}(0) = 0.
  • Smooth everywhere: The derivative is 1+βx/x2+11 + \beta x / \sqrt{x^2+1}, with no kink like the one in ReLU.

The defining feature of BLU is that it can become the identity function at β=0\beta = 0. If β\beta approaches 0 during training, the layer passes its input on to the next layer almost unchanged.

Practical considerations

Keep β\beta between −1 and 1: The derivative 1+βx/x2+11 + \beta x / \sqrt{x^2+1} is never negative when ∣β∣≤1|\beta| \le 1. With ∣β∣>1|\beta| > 1, there is a range where the output decreases as the input increases, so the function is no longer monotonic. In a PyTorch implementation, enforce the range, for example by clamping β\beta on every forward pass.

  • More expensive than ReLU: It requires a square root.
  • Output range: At β=1\beta = 1, the output is bounded below by −1 (exclusive) and unbounded above. For 0<β<10 < \beta < 1, it is unbounded in both directions.
  • No built-in PyTorch implementation: Implement it yourself (see the example below).

Comparison with other activation functions and how to choose

The table compares BLU with other activation functions, with and without learnable shape, from the same viewpoints.

FunctionLearned parameterShape near 0Output for negative inputCan it become the identity?
ReLUNoneKinked0No
PReLUNegative-side slope aaKinkedaxaxYes, at a=1a = 1
ELUNone (α\alpha is set by hand)Smooth when α=1\alpha = 1α(ex−1)\alpha(e^x - 1), approaching −α-\alphaNo
BLUβ\betaSmoothSuppressed for β>0\beta > 0 (approaches −1 at β=1\beta = 1)Yes, at β=0\beta = 0

Rough guidelines for choosing:

  • Start with ReLU: It is cheap and gives sufficient accuracy on many tasks.
  • Try BLU when you want a smooth function whose shape is tuned by training: A single parameter moves it from the identity function to a rectifier shape.
  • Try PReLU when you want a learnable shape at low cost: It learns only the negative-side slope, with no square root.

PyTorch example

Show code
python
import torch
import torch.nn as nn


def blu(x: torch.Tensor, beta: float | torch.Tensor = 1.0) -> torch.Tensor:
    # BLU(x) = β(√(x² + 1) − 1) + x
    return beta * (torch.sqrt(x**2 + 1) - 1) + x


# Example input and output (same values as the β = 1 row of the table above)
x = torch.tensor([-2.0, -1.0, 0.0, 1.0, 2.0])
print(blu(x, beta=1.0))  # tensor([-0.7639, -0.5858,  0.0000,  1.4142,  3.2361])


class BLU(nn.Module):
    """BLU with a learnable β, kept between −1 and 1."""

    def __init__(self, num_features: int, beta: float = 0.0):
        super().__init__()
        # One β per unit. The layout and initial value are just one option; here it starts at 0 (the identity function)
        self.beta = nn.Parameter(torch.full((num_features,), beta))

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        # Clamp β to [−1, 1] on every call
        return blu(x, self.beta.clamp(-1.0, 1.0))

FAQ

Q. Is BLU with β = 1 the same as ReLU?
A.

No. Both suppress the negative side, but BLU bends smoothly at x = 0, approaches −1 rather than 0 on the negative side, and its slope approaches 2 on the positive side.

Q. Why is β restricted to the range −1 to 1?
A.

Within this range the slope never becomes negative, so the function stays monotonic: the output increases as the input increases. Outside the range, there are regions where the output decreases as the input increases.

Q. What is the benefit of being able to become the identity function?
A.

The identity function neither amplifies nor shrinks gradients, so it is considered to help avoid vanishing gradients and exploding gradients even in deep networks. A layer that is not needed to represent the training data can also be effectively skipped by turning it into the identity function with β=0\beta = 0.

References

  1. L. B. Godfrey, "An Evaluation of Parametric Activation Functions for Deep Learning," IEEE International Conference on Systems, Man and Cybernetics (SMC), pp. 3006–3011, 2019.
  2. L. B. Godfrey, "Parameterizing and Aggregating Activation Functions in Deep Neural Networks," Ph.D. dissertation, University of Arkansas, 2018.
  3. S. R. Dubey, S. K. Singh, and B. B. Chaudhuri, "Activation Functions in Deep Learning: A Comprehensive Survey and Benchmark," Neurocomputing, vol. 503, 2022.
  4. S. Dai, S. Mahloujifar, and P. Mittal, "Parameterizing Activation Functions for Adversarial Robustness," arXiv:2110.05626, 2021.
  5. M. M. Hammad, "Deep Learning Activation Functions: Fixed-Shape, Parametric, Adaptive, Stochastic, Miscellaneous, Non-Standard, Ensemble," arXiv:2407.11090, 2024.