ReLU Calculator
Calculate ReLU activation function and variants for neural networks.
ReLU Parameters
f(x) = max(0, x)
ReLU(-0.5)
0.000000
Neuron is INACTIVE
ReLU
Standard ReLU, outputs 0 for negative inputs
Batch Results
What the ReLU Calculator Does
The ReLU calculator evaluates the Rectified Linear Unit activation function and its most popular variants for any input value x, returning both the output f(x) and its derivative f'(x). ReLU is the most widely used activation function in modern deep learning, and this tool lets you compute it instantly for a single value or for an entire batch of comma-separated inputs at once. Understanding how a neuron transforms its pre-activation into a final output is essential for debugging neural networks, choosing activations, and building intuition about gradient flow.
This ReLU activation calculator supports six variants used across deep learning: standard ReLU, Leaky ReLU, PReLU (parametric ReLU), ELU (Exponential Linear Unit), SELU (Self-Normalizing ELU), and ReLU6. For Leaky ReLU, PReLU, and ELU you also supply an alpha parameter that controls the behavior of negative inputs. The tool reports the activation output, the derivative used during backpropagation, whether the neuron is active or inactive, and the closed-form formula for the variant you selected.
Why does the derivative matter so much? Training a neural network with backpropagation requires the gradient of every activation. During the backward pass, the chain rule multiplies the derivative of each activation by the incoming gradient. ReLU is popular precisely because its derivative is exactly 1 for positive inputs, so gradients pass through the active region without shrinking โ sidestepping the vanishing gradient problem that plagued sigmoid and tanh networks. The trade-off is that standard ReLU has a derivative of exactly 0 for negative inputs, which can cause "dying" neurons. The variants in this calculator each offer a different remedy. Use this ReLU calculator to compare them side by side and see exactly how each one treats negative and positive values.
ReLU and Variant Formulas
Every variant in this ReLU calculator maps a real-valued input to an output, and each has a corresponding derivative used during training. The table below lists the exact forward formulas the calculator evaluates in JavaScript, where α is the alpha parameter and SELU uses the fixed constants λ = 1.0507 and αSELU = 1.6733.
| Variant | Output f(x) | Derivative f'(x) |
|---|---|---|
| ReLU | max(0, x) | 1 if x > 0, else 0 |
| Leaky ReLU | x if x > 0, else αx | 1 if x > 0, else α |
| PReLU | x if x > 0, else αx | 1 if x > 0, else α |
| ELU | x if x > 0, else α(e^x - 1) | 1 if x > 0, else αe^x |
| SELU | λx if x > 0, else λαSELU(e^x - 1) | λ if x > 0, else λαSELUe^x |
| ReLU6 | min(max(0, x), 6) | 1 if 0 < x < 6, else 0 |
Standard ReLU simply clips negative inputs to zero, which is fast and effective but discards all gradient on the negative side. Leaky ReLU and PReLU share the same forward formula โ they multiply negative inputs by a small slope α โ but PReLU treats α as a learnable parameter optimized during training, whereas Leaky ReLU keeps it fixed (commonly 0.01). ELU replaces the hard negative slope with a smooth exponential curve that saturates toward −α, pushing mean activations closer to zero. SELU scales ELU by the carefully derived constant λ = 1.0507 with αSELU = 1.6733 so that, under the right initialization, activations self-normalize toward zero mean and unit variance across layers. ReLU6 caps the output at 6, which keeps activations in a fixed low-precision-friendly range that is ideal for mobile and embedded inference.
Standard ReLU and Its Derivative
Where:
- x= The input value (the pre-activation, often a weighted sum z = wยทx + b)
- f(x)= The activation output; zero for negative inputs, x itself for positive inputs
- f'(x)= The derivative used in backpropagation; 1 on the active side, 0 on the negative side
- max= The maximum of the two arguments, returning whichever is larger
Choosing Between ReLU Variants
Picking the right activation among the six options in this ReLU variants calculator depends on your architecture, the depth of your network, and the training stability you observe. There is no universally best choice, but there are clear, well-established guidelines.
Standard ReLU is the default for most convolutional and fully connected hidden layers. It is cheap to compute, plays well with modern initialization, and rarely needs tuning. The main failure mode is the dying ReLU problem: if a neuron's weights push its pre-activation persistently negative, its output and gradient both become zero and it stops learning. Plug a few representative negative values into the calculator and watch the derivative drop to 0 to see this directly.
Leaky ReLU fixes dying neurons by leaking a small gradient through negative inputs. A typical α is 0.01, which keeps a slope of 0.01 on the negative side so the unit can always recover. PReLU takes this one step further by learning α per-channel during training, which can boost accuracy on large image datasets at the cost of a few extra parameters.
ELU swaps the linear negative slope for a smooth exponential that saturates at −α, producing negative outputs that nudge the mean activation toward zero and often speed up convergence. SELU is ELU with fixed scaling constants designed for self-normalizing networks; it works best with the LeCun-normal initialization and alpha-dropout, and can remove the need for batch normalization in deep fully connected stacks. ReLU6 bounds the activation to the interval [0, 6], which is the standard choice in MobileNet and other quantization-friendly architectures because the fixed range maps cleanly onto 8-bit integers. A practical workflow: start with ReLU, switch to Leaky ReLU or ELU if you observe many dead units, and reach for ReLU6 only when you are targeting low-precision mobile inference.
Derivatives, Gradients, and the Dying ReLU Problem
The reason this ReLU calculator reports a derivative alongside every output is that the derivative is what actually drives learning. During backpropagation, the gradient flowing back into a neuron is multiplied by that neuron's activation derivative. For standard ReLU the derivative is a clean step function: exactly 1 wherever the input is positive and exactly 0 wherever it is negative. This binary behavior is both ReLU's greatest strength and its central weakness.
On the positive side, a derivative of 1 means gradients pass through unattenuated. Stack many ReLU layers and the gradient does not shrink the way it would with sigmoid, whose derivative peaks at just 0.25. This is the core reason ReLU enabled the training of very deep networks and largely solved the vanishing gradient problem for feedforward and convolutional models.
On the negative side, a derivative of 0 means no gradient flows at all. If a neuron lands in the negative region for every training example, it receives zero gradient, its weights never update, and it is effectively dead. This is the dying ReLU problem, and it is the motivation for nearly every variant. Leaky ReLU and PReLU keep the negative derivative at α instead of 0; ELU keeps it at αe^x, which is always positive; and SELU keeps it at λαSELUe^x. ReLU6 reintroduces a second zero-gradient region above x = 6, so its derivative is 1 only on the open interval (0, 6). Use the batch-input field to feed a spread of negative and positive values and confirm which variant preserves gradient signal where your network actually operates โ that hands-on comparison is the fastest way to diagnose stalled training.
How to Use This ReLU Calculator
This ReLU calculator is built for quick experimentation, so you can go from a question to a verified answer in seconds. Start by entering an input value (x) in the first field โ this is the pre-activation, the weighted sum your neuron produces before the nonlinearity is applied. The large result card shows the activation output immediately, along with a clear ACTIVE or INACTIVE label based on whether the output is greater than zero.
Next, pick a ReLU variant from the dropdown: Standard ReLU, Leaky ReLU, PReLU, ELU, SELU, or ReLU6. When you select Leaky ReLU, PReLU, or ELU, an alpha field appears so you can tune the negative-region behavior. SELU and ReLU6 use fixed internal constants and therefore do not expose alpha. The formula panel updates live to show the exact closed-form expression for your current selection, and a Derivative card reports the gradient at your chosen input.
To evaluate a whole layer at once, use the batch input field and enter comma-separated numbers such as -2,-1,0,1,2. The calculator parses each value, applies the selected activation, and lists every result with an Active or Off badge so you can scan an entire vector at a glance. This is the fastest way to visualize how an activation reshapes a distribution of pre-activations โ for example, watching standard ReLU zero out everything below the threshold while Leaky ReLU preserves a faint negative tail. Combine the single-value view, the derivative card, and the batch list to build a complete picture of how your chosen activation behaves across the input range your model produces.
Worked Examples
Standard ReLU on a Negative Input
Problem:
Compute standard ReLU for x = -0.5 and report the output, derivative, and whether the neuron is active.
Solution Steps:
- 1Apply the ReLU formula f(x) = max(0, x), so f(-0.5) = max(0, -0.5).
- 2Since 0 is larger than -0.5, the maximum is 0, giving an output of 0.000000.
- 3The derivative is 1 if x > 0, else 0. Because -0.5 is not greater than 0, the derivative is 0.000000.
- 4The output is not greater than 0, so the neuron is INACTIVE for this input.
Result:
f(-0.5) = 0.000000, derivative = 0.000000, neuron INACTIVE.
Leaky ReLU on a Batch with Alpha = 0.01
Problem:
Apply Leaky ReLU with alpha = 0.01 to the batch -2, -1, 0, 1, 2.
Solution Steps:
- 1For positive inputs use f(x) = x; for non-positive inputs use f(x) = 0.01x.
- 2x = -2 gives 0.01 * -2 = -0.0200; x = -1 gives 0.01 * -1 = -0.0100; x = 0 gives 0.0000.
- 3x = 1 stays 1.0000 and x = 2 stays 2.0000 because both are positive.
- 4Negative inputs keep a small nonzero output, so no neuron in this batch is fully dead.
Result:
Outputs: -0.0200, -0.0100, 0.0000, 1.0000, 2.0000.
ELU on a Negative Input with Alpha = 1
Problem:
Compute ELU for x = -1 with alpha = 1, including the derivative.
Solution Steps:
- 1For x <= 0, ELU uses f(x) = alpha * (e^x - 1) = 1 * (e^(-1) - 1).
- 2Since e^(-1) is approximately 0.367879, the output is 0.367879 - 1 = -0.632121.
- 3The ELU derivative for x <= 0 is alpha * e^x = 1 * e^(-1) = 0.367879.
- 4Unlike standard ReLU, the gradient here is nonzero, so the neuron can still learn.
Result:
f(-1) = -0.632121, derivative = 0.367879.
SELU and ReLU6 at the Extremes
Problem:
Compute SELU for x = -1 and ReLU6 for x = 8 using the calculator's fixed constants.
Solution Steps:
- 1SELU uses lambda = 1.0507 and alpha = 1.6733; for x <= 0, f(x) = lambda * alpha * (e^x - 1).
- 2f(-1) = 1.0507 * 1.6733 * (e^(-1) - 1) = 1.758186 * (-0.632121) โ -1.111354.
- 3ReLU6 uses f(x) = min(max(0, x), 6); for x = 8, max(0, 8) = 8 and min(8, 6) = 6.
- 4The ReLU6 derivative is 0 at x = 8 because 8 is not inside the open interval (0, 6).
Result:
SELU(-1) โ -1.111354; ReLU6(8) = 6.000000 with derivative 0.
Tips & Best Practices
- โStart with standard ReLU for hidden layers; it is fast and rarely needs tuning.
- โIf you see many dead neurons stuck at zero, switch to Leaky ReLU or ELU to keep a nonzero negative gradient.
- โUse a small alpha like 0.01 for Leaky ReLU; larger values reduce the rectifying benefit.
- โReach for ReLU6 when targeting mobile or 8-bit quantized inference where bounded activations matter.
- โPair SELU with LeCun-normal initialization and alpha-dropout to preserve its self-normalizing property.
- โFeed both negative and positive batch values to confirm where each variant keeps a useful derivative.
- โRemember PReLU and Leaky ReLU share a formula here; the difference is whether alpha is learned during training.
- โWatch the derivative card, not just the output, since the derivative is what actually drives learning.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the ReLU Calculator?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various