What is the ReLU activation function?
The Rectified Linear Unit, or ReLU, is one of the most widely used activation functions in modern neural networks. It is defined as \(f(x) = \max(0, x)\): for any positive input it returns the input unchanged, and for any negative input it returns zero. This simple piecewise-linear rule introduces non-linearity into a network while being extremely cheap to compute and easy to differentiate.
How to use this calculator
Enter three values: the initial value of x (where the sweep begins), the increment or step size (how much x changes each iteration), and the number of repetitions (how many points to generate). The tool evaluates ReLU at each x value, builds a complete (x, f(x)) data table, and draws a line graph showing the characteristic flat-then-rising shape with its corner at the origin.
The formula explained
ReLU is \(f(x) = \max(0, x)\), which is equivalent to "x if x > 0, else 0". The sweep is generated by the rule $$x_k = \text{startX} + k \cdot \text{stepX}, \quad k = 0,1,\dots,\text{iterations}-1$$ so the final x value (endX) equals \(\text{startX} + (\text{iterations} - 1) \cdot \text{stepX}\). The function is flat at zero across all negative inputs, then rises with a constant slope of 1 for positive inputs.
Worked example
Using the defaults startX = -5, stepX = 0.1, and iterations = 101, the sweep covers x from -5 up to \(-5 + 100 \cdot 0.1 = +5\) across 101 inclusive points. At x = -2.0, \(f = \max(0, -2.0) = 0\). At x = 0, \(f = 0\). At x = 0.1, \(f = 0.1\). At x = 2.5, \(f = 2.5\). At x = 5.0, \(f = 5.0\). The plotted curve sits at zero throughout the negative range, then climbs linearly to (5, 5).
FAQ
Is ReLU differentiable at zero? No. ReLU has a corner (kink) at x = 0, so it is not differentiable there. Its derivative is 0 for x < 0 and 1 for x > 0; by convention the derivative at 0 is often taken as 0.
Can the step be negative? Yes. A negative step sweeps x downward. A step of zero makes every x equal to the starting value (a degenerate constant column).
Why is ReLU so popular? It avoids the vanishing-gradient problem of sigmoid and tanh for positive inputs, is computationally trivial, and tends to produce sparse activations, which often speeds up training.