Activation function
An activation function is the mathematical rule each neuron in a neural network applies to its weighted inputs, adding the non-linearity that lets the network learn complex patterns.
Every artificial neuron does two things. It adds up its inputs, each multiplied by a learned weight, and then passes that total through an activation function before handing the result to the next layer. Google's machine learning glossary sums up the purpose: the activation function is what lets a neural network learn non-linear relationships between its inputs and the answer it is trying to predict.
That matters because a chain of purely linear steps collapses into a single linear step. Without a non-linear activation, a network with a hundred layers could express nothing more than a network with one. With one, even a network of two layers can in principle approximate a very wide range of functions, a result known as the universal approximation theorem.
For decades the standard choices were the sigmoid, which squashes any number into the range 0 to 1, and tanh, which squashes it into the range minus 1 to 1. Both flatten out for large inputs, so the signal used to adjust the weights during training becomes tiny, and deep networks learn slowly. This is the vanishing gradient problem. The rectified linear unit, or ReLU, is far simpler: it outputs zero for negative inputs and passes positive inputs through unchanged. Because it does not flatten out for positive values, it trains deep networks more easily, and it was used in AlexNet, the 2012 image recognition model that helped start the deep learning boom.
Language models brought further refinements. In June 2016 Dan Hendrycks and Kevin Gimpel proposed GELU, a smooth relative of ReLU that weights each input by how likely a standard Gaussian variable is to fall below it; BERT used it in 2018. In 2020 Noam Shazeer reported that some gated variants, which multiply two parallel projections together after passing one through an activation, improved quality over both ReLU and GELU in transformer feed-forward layers. Mixtral 8x7B, described in a January 2024 paper, builds its experts from one such variant, SwiGLU.
At the very end of many networks sits a different kind of function, softmax, which turns a list of raw scores into probabilities that add up to one. In a classifier those are the probabilities of each class; in a language model they are the probabilities of each possible next token. For anyone reading AI news, activation functions are a low-level design detail: a model announcement may mention a switch from one to another, but the choice is one tuning decision among many rather than a source of new abilities.
Without them, every layer would perform a linear calculation, and any stack of linear calculations is equivalent to a single one. The network could then only learn straight-line relationships, however many layers it had. A non-linear activation function lets each layer bend and combine signals, which is what allows deep networks to model complicated patterns in images, speech and text. ReLU stands for rectified linear unit. It outputs zero when its input is negative and passes the input through unchanged when it is positive. It is cheap to compute and avoids the flattening that slows training with older functions such as the sigmoid, which is why it became a default choice for deep networks after its use in AlexNet in 2012. Transformer language models have mostly moved from ReLU to smoother or gated functions. BERT used GELU in 2018, and a 2020 paper by Noam Shazeer found that some gated variants performed better in transformer feed-forward layers. Mixtral 8x7B, for example, uses SwiGLU blocks. The exact choice varies by model and is usually listed in its technical report. Training adjusts weights using gradients, signals that say how much each weight contributed to an error. Functions like the sigmoid and tanh flatten out for large inputs, so their gradients shrink towards zero, and in a deep network those small values multiply together layer after layer. Early layers then barely learn. Non-saturating functions such as ReLU make this much less likely.Common questions
Why do neural networks need activation functions?
What is ReLU?
Which activation function do large language models use?
What is the vanishing gradient problem?
Search for "activation function ReLU GELU", "vanishing gradient problem" or "GLU variants transformer" to see how the choices compare. The most reliable sources are the original papers on arXiv, machine learning course material from universities and from Google, and the documentation of frameworks such as PyTorch, which define each function precisely. Model technical reports state which activation a given model uses; treat blog posts that rank activation functions with care, since results depend heavily on the model and task tested.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.