Black October, explainedAppsGuidesAI DictionarySmall FixesOn RecordAboutFollow the lab

Activation function

Also called ReLU, sigmoid, activation

An activation function is the small rule each artificial neuron applies to its total before passing it on, adding the bend that lets networks learn complex patterns.

In plain words

Every artificial neuron adds up its weighted inputs into one number. Before passing that number on, it runs it through a simple rule. That rule is the activation function.

The most popular rule today, called ReLU, is almost comically simple: if the number is negative, send 0; if it is positive, send it unchanged. Another classic, the sigmoid, squashes any number into a value between 0 and 1.

Why bother? Without such a rule, every layer would just be adding and multiplying, and a stack of those is no more powerful than a single layer: a straight line on top of a straight line is still a straight line. The bend from the activation function is what lets a neural network model curves, edges, faces and language.

Everyday example

The overflow pipe on a water tank

A rooftop tank has an overflow pipe near the top. Below that level, nothing comes out of the pipe, however much the level changes. Above it, the more water there is, the more pours out. That is ReLU: below zero, no output; above zero, output grows with the input.

Where the example breaks: The tank is a physical system with one fixed level. In a network, the threshold effectively shifts because each neuron has a learned bias, and billions of these simple bends combine into shapes no single tank could make.

Go deeper

How it actually works

Formally, the activation function is applied to a neuron's weighted sum to produce its output. It must be nonlinear for depth to add power.

  1. Why nonlinear

    If every neuron just passed on its weighted sum, the whole network would collapse into one big weighted sum, however many layers it had. Google's glossary puts it plainly: activation functions let networks learn nonlinear relationships, and their plots are never single straight lines.

  2. Sigmoid and tanh

    The sigmoid, 1 / (1 + e^−x), squashes inputs into 0 to 1; tanh squashes into −1 to 1. They were standard until around 2010, but in deep networks their flat ends make the training signal fade, the vanishing gradient problem.

  3. ReLU

    ReLU, max(0, x), became common around 2010. It is cheap and keeps a strong signal for positive values. The 2012 AlexNet paper reported that networks with ReLUs trained several times faster than with tanh.

  4. Its weak spot

    A ReLU neuron whose input stays negative always outputs 0 and stops learning, a dead ReLU. Variants such as Leaky ReLU let a little signal through below zero.

  5. Today's variants

    Many modern transformers use smoother cousins of ReLU. At the output, a function called softmax turns raw scores into probabilities that add up to 1, for example over the next token.

Most popular
ReLU: negative becomes 0, positive passes unchanged
Classic
Sigmoid (0 to 1) and tanh (−1 to 1)
ReLU history
Used by Kunihiko Fukushima in 1969; became common in deep learning around 2010
Purpose
Adds nonlinearity, so stacked layers can model complex patterns

Questions people ask

What is an activation function in simple words?

A simple rule a neuron applies to its total before passing it on. For example, ReLU says: if the total is negative, output 0, otherwise output the total. That small bend is what lets neural networks learn complicated patterns.

Why do neural networks need activation functions?

Without them, every layer is just multiplying and adding, and any number of such layers equals one layer. Activation functions add bends, so deep networks can represent curves and complex relationships instead of only straight lines.

What is ReLU?

Rectified Linear Unit, the most widely used activation function. It outputs 0 for any negative input and the input itself for any positive input. Google's example: −3 becomes 0, and 3 stays 3.

What is the difference between ReLU and sigmoid?

Sigmoid squashes every input into a value between 0 and 1, which flattens out for large inputs and can slow learning in deep networks. ReLU keeps positive values as they are and zeroes negatives; it is simpler and usually trains faster.

Further reading