AI Grounds

Open AI Grounds on a desktop

These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.

Guided discovery

Activation Functions Lab

Change the input. Compare three activation rules.

Your dataset

One scalar input x passes through a fixed activation, an input-output rule. ReLU means rectified linear unit; tanh means hyperbolic tangent. All three rules use the same input. Choosing Activation keeps x fixed, while editing Input value recomputes all outputs. No learned weights, bias or training is supplied.

Input x

2

Selected rule

ReLU

max(0,2)

Output

2

A shared scalar input in tenths. All rules transform the same x; the selected rule determines the primary output. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

ReLU(2) = 2 · Zero for nonpositive inputs, unchanged positive inputs; no global upper bound.

Actual input or function changes clear stale explanations and transfer answers. Unchanged controls preserve them. Display values round to six decimals; calculations use full precision. A bounded sigmoid output by itself is not evidence of a trained or calibrated class probability.

ReLU

Zero for nonpositive inputs, unchanged positive inputs; no global upper bound.

2

max(0,x)

Fixed input 2: 2. Current output minus that reference: 0.

Sigmoid

Strictly between 0 and 1 for finite real inputs; at zero it is 0.5.

0.880797

1 / (1 + exp(−x))

Fixed input 2: 0.880797. Current output minus that reference: 0.

Tanh

Strictly between −1 and 1 for finite real inputs; negative inputs give negative outputs.

0.964028

(exp(x) − exp(−x)) / (exp(x) + exp(−x))

Fixed input 2: 0.964028. Current output minus that reference: 0.

Compare each fixed rule

exp(x) is the exponential e raised to x, where e is about 2.71828. ReLU is max(0,x). Sigmoid is 1/(1+exp(−x)); tanh is (exp(x)−exp(−x))/(exp(x)+exp(−x)). At input 0, exp(0)=1 gives sigmoid 0.5 and tanh 0. Saturation means approaching a bound with smaller output changes, not becoming exactly constant at a finite input here.

Reference input 2 remains fixed across scenarios and function changes. Every current output uses the same x; changes are f(x)−f(2), computed before display rounding.
ActivationCurrent xCurrent outputFixed x=2 outputChange from x=2
ReLU2220
Sigmoid20.8807970.8807970
Tanh20.9640280.9640280
Compare the curves

All curves share input −6..6 and output −1..6. Circle/solid line=ReLU; square/dashed=Sigmoid; diamond/dotted=Tanh. A navy outline highlights the selected output at the shared input guide. Shapes, patterns, labels and the exact table accompany color; coincident markers draw the selected one last.

-6-4-20246-10123456Sigmoid at input 2 gives 0.880797Tanh at input 2 gives 0.964028ReLU at input 2 gives 2Input xy

Curves connect the 121 supported input positions in steps of 0.1. Values and marker positions are exact at those positions up to floating arithmetic; straight segments between them are illustrative. The editor’s maximum6 is not a mathematical upper bound on ReLU. Sigmoid and tanh approach their ideal bounds without reaching them at any supported input.

Construction and limits

The input is encoded as an integer−60..60 divided by 10, with no weights, bias, network layers or dataset. ReLU uses max(0,x), sigmoid uses1/(1+exp(−x)), and tanh uses the hyperbolic tangent. These fixed scalar functions can also be applied element by element in a tensor, but tensor behavior is outside this lesson.

For finite real inputs, sigmoid lies strictly between 0 and1 and tanh strictly between −1 and1. At the supported endpoints, sigmoid(6)≈0.997527 and tanh(6)≈0.999988; neither is exactly1. ReLU is zero at and below 0 and has no global upper bound. No derivatives, gradient at the ReLU kink, optimization, learned representation, calibrated probability or recommendation of an activation for a task is claimed.

Reference input 2 is fixed for each activation. Changing function preserves input; changing input recomputes all three functions. Reset/prediction restores Positive input 2/ReLU for the current experiment; free Reset begins Experiment 1. Ordinary display rounding is not used for subsequent calculations or mastery checks. The optional common-axis curves have121 vertices and preserve this same numeric model.

PyTorch · ReLU definition
PyTorch · Sigmoid definition
PyTorch · Tanh definition