ATLAS NOVA My AtlasVelocer ↗

Technology · Machine learning

Activation function

Neural network nonlinearity

An activation function is the fixed rule applied to a neuron's weighted input before that value is passed on to the next layer of an artificial neural network.

A neuron first gathers signals from the units feeding into it, weighting each one, and adds them into a single number. That number does not travel onward unchanged. It is fed through the activation function, and the result becomes the neuron's output. The function is what gives the network its nonlinearity: without it, a stack of layers would collapse into one large linear transformation, no matter how many layers were piled up.

Key facts
0.9Swish over ReLU improved ImageNet top-1 accuracy by this percent for Mobile NASNet-A (Ramachandran et al., 2017)⁠[1]
2.1Mish beat leaky ReLU on YOLOv4 by this percent average precision on MS-COCO (Misra, 2019)⁠[2]
7.51Learned per-neuron piecewise activation reached this CIFAR-10 error percent (Agostinelli et al., 2014)⁠[3]
10Independent randomized trials per condition in the ReLU, tanh and sigmoid comparison (Agarap, 2018)⁠[4]

Overview

Activation function

A concrete case makes the idea plain. The rectified linear unit, usually shortened to ReLU, outputs its input when the input is positive and outputs zero when the input is negative. Written as a formula, it is the larger of zero and the input. A neuron receiving a weighted sum of 3.7 passes 3.7 onward; one receiving a weighted sum of minus 2 passes zero. The rule is trivial to compute, yet it bends the relationship between input and output at the point where the sign changes, and that bend is what the rest of the network can build on.

A weighted-input neuron feeds a ReLU block beside its piecewise linear graph, with worked paths for inputs −2 and 3.7 and three numbered explanation boxes.
ReLU returns zero for negative weighted sums and passes positive values unchanged. The graph and worked examples show the bend that introduces nonlinearity. View full-size image.How ReLU Transforms a Neuron’s Input by Atlas Nova. Illustration generated with AI for this article and checked against its text.

Why is the bend necessary? A network learns by adjusting weights so that its outputs match the desired answers on many examples. If every neuron simply passed its weighted sum through unchanged, then composing layers would amount to multiplying matrices, and the whole network would be equivalent to a single linear map. Such a map can only express relationships that are straight lines, planes, or their higher-dimensional analogues. Real tasks, such as telling a cat from a dog in a photograph or predicting a price from a dozen interacting factors, involve curved, tangled relationships that no single linear map can capture. The activation function is the ingredient that lets stacked layers represent those complicated mappings between inputs and corresponding outputs.⁠[5]

The choice of function is not a cosmetic detail. Different activation functions change how signals grow or shrink as they pass through many layers, and therefore change how easily the network can be trained and how accurately it performs once trained. A survey of the functions used in deep learning describes them as performing diverse computations between the hidden layers and the output layer of a given architecture, and notes that the choice bears directly on the performance those architectures achieve. The same survey observes that a large number of activation functions have been proposed, and that practical deployments draw on this variety rather than settling on one form.⁠[6]

That variety reflects a genuine absence of consensus. No single activation function has been established as best for every task. Yet the search for better functions continues, and the sections that follow trace where the idea came from, how the function operates inside a layer, which shapes are in common use, where these functions are applied, what the comparative evidence shows, what can go wrong, and how the choice is increasingly being automated.

An activation function is a small nonlinear rule applied at every neuron; its shape decides what a network can learn and how well it trains.

History

From biological neurons to rectified linear units

Artificial neural networks take their name and their rough architecture from the brain. The brain's neurons are connected through synaptic junctions, and a signal arriving at one of these junctions is passed along to the next cell; an artificial network imitates this arrangement with layers of units wired to one another, where the output of an inner layer is handed forward to the next and finally to the outermost layer that produces the answer.⁠[5] The borrowing is structural rather than literal. An artificial unit does not fire in the way a biological cell does, and the resemblance lies in the pattern of many simple elements passing signals through a layered network, not in any claim that the two compute the same way.

Figure 1. Top-1 accuracy gain from replacing ReLU with Swish on ImageNet. The chart shows the percentage-point improvement in top-1 classification accuracy when Swish units replace ReLU units in two models. The source states: “simply replacing ReLUs with Swish units improves top-1 classification accuracy on ImageNet by 0.9\% for Mobile NASNet-A and 0.6\% for Inception-ResNet-v2” (Ramachandran et al. (2017)).⁠[1]

What the early networks lacked was a way to do anything but add and scale. A layer that merely sums its weighted inputs is a linear operation, and stacking linear operations yields another linear operation. The activation function entered as the remedy: the inner layers' output is given nonlinearity before it is passed on, so that the network can represent the complicated, curved relationships between inputs and corresponding outputs rather than only straight ones.⁠[5] This is the role the function has carried ever since, whatever shape it takes.

The shapes themselves have a history. Sigmoid and hyperbolic tangent are saturating functions, both of which bend their input into a smooth S-curve and flatten out toward their limits at large positive and negative values.⁠[4] A flattened region is a region where the slope is nearly zero, and a network trained by following slopes has little to follow there. Non-saturating functions keep a usable slope across a wide range of inputs, and the same comparison argues that non-saturating functions are necessary in deep architectures. The rectified linear unit passes positive values through unchanged and clips negative ones to zero, and it is described there as a foundational activation function in artificial neural networks.⁠[4]

A 2018 paper devoted to ReLU traces the mathematical lineage of piecewise linear functions through to their definitive integration into deep learning by Nair & Hinton (2010). A 2018 paper devoted to ReLU notes that the literature has frequently misattributed the function's origin to that 2018 paper itself, and sets out to correct the record by tracing the mathematical lineage of piecewise linear functions from early biological models through to their definitive integration into deep learning by Nair and Hinton.⁠[4] The same paper is not only a historical correction; it also runs a controlled comparison of ReLU against the older sigmoid and tanh, which is taken up later.

The lineage is worth pausing on, because it explains why the rectified shape feels inevitable in hindsight.

The shift from saturating to non-saturating functions was therefore not a matter of taste. Sigmoid and tanh compress their inputs into a bounded range, and sigmoid failed to converge in deep convolutional vision tasks due to the vanishing gradient problem, yielding accuracies equivalent to random probability.⁠[4] A rectified unit does not compress its positive inputs at all; it either passes them or blocks them. ReLU is currently the most successful and widely-used activation function.⁠[1]

How it works

What the function does inside a layer

Inside a single artificial neuron, the activation function sits at the end of a short sequence. The unit collects the outputs of the neurons feeding into it, multiplies each by a weight, and adds the products together with a constant term called the bias, which shifts the total up or down. That weighted sum is the neuron's raw input. The activation function is then applied to it, and the result, a single number, becomes the neuron's output and travels along the connections to the next layer. The same three steps repeat at every unit, so a layer of neurons is a bank of weighted sums each passed through the same rule.

Two weighted input branches merge at a summation node, pass through ReLU, and carry red gradient arrows backward.
A worked ReLU neuron combines weighted inputs and a bias to produce its output. Red arrows show the backward gradients for the two weights. View full-size image.Values and Gradients Inside a Neuron by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The reason the rule must be nonlinear is a matter of composition. If each unit passed its weighted sum through unchanged, then a layer would compute a weighted sum of weighted sums, which is still a weighted sum, and any number of such layers would reduce to one linear map. A linear map can only produce straight-line relationships: double an input and the output doubles, add two inputs and the outputs add. Curved relationships, the kind that separate one category of input from another or predict an outcome from factors that interact, cannot be built from straight pieces alone. Giving the inner layers' output a nonlinearity before it is passed on is what allows the network to represent complicated mappings between inputs and corresponding outputs.⁠[5] Each activation bends the space a little, and the next layer's weights then combine those bends into shapes no single layer could produce.

A useful way to picture this is to think of what a deep stack does to the input space. The first layer draws a set of straight boundaries through the input and folds the space along them; the activation decides how sharply each fold is made. The second layer draws boundaries through the folded space, which in the original coordinates are curved. With enough units and enough layers, the folds accumulate until the network can carve out almost any region it needs. The activation function is what makes each fold a fold rather than a harmless relabeling, and the shape of the function determines whether the fold is gentle, sharp, or one-sided.

That shape has consequences for training, because a network learns by measuring how wrong its outputs are and then nudging each weight in the direction that reduces the error. The size of the nudge depends on the slope of the error with respect to the weight, and that slope is computed by working backward through the layers, multiplying together the slopes of the activation functions along the way. A function whose slope is close to zero over much of its range contributes a factor near zero to that product. When many such factors are multiplied together in a deep network, the product shrinks toward nothing, and the weights in the early layers barely move. This is the vanishing gradient problem: the signal that tells a network how to improve fades before it reaches the layers that most need it.

Saturating functions are the ones that cause it. A function saturates when its output flattens out for large inputs, so that increasing the input further changes the output hardly at all. The sigmoid and the hyperbolic tangent both behave this way at their two extremes, and a unit sitting in a saturated region has a slope near zero, which is precisely the factor that kills the backward signal. The empirical consequence is stark. In a comparison of ReLU, tanh and sigmoid run over ten independent randomized trials and tested with a non-parametric Kruskal-Wallis test, the sigmoid failed to converge in deep convolutional vision tasks because of the vanishing gradient problem, reaching accuracies equivalent to random probability, while ReLU and tanh both converged stably.⁠[4] The failure was not a matter of tuning; it followed from the shape of the function in a deep stack.

A rectified unit avoids saturation on its positive side by not flattening at all: however large the input, the output grows in step with it, and the slope stays at one. On the negative side the slope is exactly zero, which is a different kind of problem, since a unit whose input stays negative receives no gradient and stops changing. That failure mode is taken up later. The point here is the trade the rectified shape makes: it gives up the smooth bounded output of the older functions in exchange for a live gradient wherever the unit is active.

Saturation also affects what a unit's output means. A function that flattens toward a fixed value at its lower end compresses all sufficiently negative inputs into nearly the same output, so the unit can no longer distinguish a mildly negative input from a strongly negative one. The exponential linear unit behaves this way: it saturates to a negative value with smaller inputs and thereby decreases the forward propagated variation and information, so that it codes the degree of presence of particular phenomena in the input while not quantitatively modeling the degree of their absence.⁠[7] A saturating floor thus acts as a soft switch, reporting presence but not the size of an absence.

Saturation is not only a defect to be engineered around. A function that flattens can also hide dependencies from a training procedure that follows first-order gradients alone, because the slope it needs to climb is invisible in the flat region. One response is to inject noise into the problematic parts of the function so that gradients can flow even where the noiseless application would yield zero, letting the optimizer explore the boundary between the degenerate and well-behaved regions; the approach connects to simulated annealing when the amount of noise is reduced over training, and replacing saturating functions with noisy variants was found to help training in many contexts, yielding state-of-the-art or competitive results on different datasets and tasks, especially when training was most difficult.⁠[8] The flat region, in other words, can be made passable rather than merely avoided.

The output of the activation is what the next layer actually sees, so its range and distribution shape everything downstream. A bounded function keeps activations within a fixed interval, which can steady the arithmetic but risks the compression just described. An unbounded one lets activations grow with the input, which preserves information but can let values drift large. Neither is universally right, and the choice interacts with how deep the network is and how its weights are initialized. What the function does inside a layer, in the end, is decide how strongly each unit responds, how much of that response survives the trip backward during learning, and therefore which parts of a stacked network can actually be trained.

The activation sets both what a unit passes forward and how much gradient flows back; a flat slope anywhere in that path is a place where learning stalls.

The main families and their shapes

The functions in common use fall into a few families, and each family can be read as an answer to a problem the previous one left open. The saturating kind includes the logistic sigmoid and the hyperbolic tangent, or tanh [20,49]. Both are smooth S-curves. Near zero they behave almost linearly, and at their two extremes they flatten into horizontal asymptotes, so that a very large input and an even larger one produce nearly the same output. That flattening is what makes them useful when an output should look like a probability, and it is what makes them troublesome in a deep stack, for the reason already given: a flat stretch has a slope near zero, and a slope near zero strangles the backward signal.

The second family is the rectified one, and its members differ only in what they do on the negative side. The plain rectified linear unit has an identity for positive values. The parametrized ReLU is a variant that, like the leaky ReLU, takes negative values but does not ensure a noise-robust deactivation state.⁠[7] All three keep the identity on the positive side, which is the property that made the family attractive in the first place: no compression, no ceiling, a slope of exactly one however large the input grows.

The exponential linear unit, or ELU, keeps the identity for positive inputs and saturates to a negative value with smaller inputs. Its designers describe the aim directly: unlike the rectified unit, the ELU takes negative values, which pushes the mean of a unit's activations closer to zero, and it does so with lower computational cost than the normalization step that would otherwise be needed to achieve the same centering. The same account draws a contrast with the leaky and parametrized variants, which also take negative values but do not ensure a noise-robust deactivation state; the ELU's saturating floor means that small inputs produce outputs bunched near that floor, which decreases the variation and information propagated forward, so the unit reports how strongly a feature is present without trying to measure how strongly it is absent.⁠[7] A negative branch that flattens, in other words, is a deliberate soft switch rather than an oversight.

The third family is smooth and non-monotonic: the output rises, then dips slightly, then rises again. Swish is defined as the input multiplied by the sigmoid of a scaled input, f(x) = x · sigmoid(βx). It was not designed by hand but found by automatic search: a combination of exhaustive and reinforcement-learning-based search over candidate functions turned up several novel forms, and the best of them, written as the input times the sigmoid of a scaled input, was named Swish. The authors note its simplicity and its similarity to the rectified unit, which makes it easy to swap in for an existing rectified unit in any network.⁠[1] Mish belongs to the same family and is defined as the input times the hyperbolic tangent of the softplus of the input, where the softplus is a smooth version of the rectified shape; it is described as a self-regularized non-monotonic function, and its formulation is explored in relation to the Swish family, with the behavior of its first derivative proposed as the mechanism by which it acts as a regularizer during optimization.⁠[2]

A fourth family abandons the idea that the function should be monotonic or saturating at all and uses a periodic shape. A periodic activation function is one that repeats its values at regular intervals, such as the sine. Networks built with sine activations, called sinusoidal representation networks, were proposed for representing continuous signals: images, wavefields, video, and sound, together with their spatial and temporal derivatives.⁠[9]

The motivation is specific to that job. A signal defined implicitly as the solution to a differential equation has derivatives that matter as much as its values, and the older architectures for such representations were incapable of modeling signals with fine detail and failed to represent a signal's derivatives. Sirens use periodic activation functions and are suited to representing complex natural signals and their derivatives. The same work analyzes Siren activation statistics to propose a principled initialization scheme.⁠[9]

These families are not a ranked list, and the survey literature treats them as a menu rather than a ladder. One compilation of the functions used in deep learning sets out to gather the majority of them and to outline current trends in their application, precisely so that a practitioner can make an informed choice for a given deployment.⁠[6] The shapes differ in what they do to positive inputs, what they do to negative ones, whether their slope stays usable across the whole range, and how much arithmetic each costs. A function that is cheap and unbounded on the positive side, with a small live slope on the negative side, solves a different set of problems from a smooth bounded curve or a periodic wave.

The variety also has a practical cost, because a shape that helps in one setting can hurt in another, and the comparative record is mixed enough that no family has swept the field. Hand-designed alternatives to the rectified unit have generally failed to replace it because their gains have been inconsistent.⁠[1] What the shapes share is the underlying job: each takes a weighted sum and returns a number, and each is chosen for how that number behaves at the edges of its range and how much slope it offers on the way back during learning. The sections that follow take up where these functions are put to work, how they have fared when measured against one another, and what happens when a shape turns out to be the wrong one for the task.

The families differ mainly in three choices: what happens to negative inputs, whether the slope stays alive across the range, and how smooth the curve is.

caption: The main activation families differ mainly in their behavior at large and negative inputs.

Uses

Where activation functions are used

The activation function is not confined to one kind of network. It appears wherever a layer of weighted sums has to be bent into something more expressive, and the settings in which it does that work range from recognizing a face in a photograph to representing the shape of a sound wave to building a neuron out of light.

A diagram in Hindi labeled as a convolutional neural network, showing an input image of a rabbit on a page, feature-learning layers of stacked feature maps, a flatten step, fully connected layers, and output classes with scores for a rabbit-like label, horse, and pig.
A diagram in Hindi labeled as a convolutional neural network, showing an input image of a rabbit on a page, feature-learning layers of stacked feature maps, a flatten step, fully connected layers, and output classes with scores for a rabbit-like label, horse, and pig. View full-size image.Convolutional-Neural-Network-Hindi by Irisbox. CC BY 4.0, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

The most familiar setting is the convolutional neural network, a network that slides small filters across an image to detect local patterns such as edges and textures and assembles those patterns into larger features in successive layers. A survey of the architecture describes its fundamental ingredients as the layers, the convolution operation, the resulting feature maps, and the activation functions, alongside the methods used to train it.⁠[10] The activation sits after each convolution, bending the filtered response before it is passed deeper. The same survey notes that convolutional networks have been applied well beyond images, including speech recognition, natural language processing, and the classification of DNA sequences, so the activation's role travels with the architecture rather than belonging to vision alone.⁠[10]

Facial expression recognition is a concrete case where the function is treated as the central design decision. A study of a convolutional model for that task argues that the activation function is the core of the architecture, because it is the nonlinear ability of the function that gives a deep network its genuine capacity to learn. The same work notes a shortcoming of the rectified unit that matters in this setting: its derivative is always zero when the input is negative, so units can stop responding altogether, a failure the study calls neuronal necrosis.⁠[11] That failure mode and its remedies are taken up later; what matters here is that a task built on subtle differences in facial configuration depends on every unit staying alive to contribute.

Text is handled by the same machinery with a different input. Words or fragments of words are turned into vectors and passed through layers whose activations bend the representation, and the same comparative work that tests functions on images also tests them on text classification, treating the two as parallel demonstrations of the same underlying question.⁠[4] The function does not know whether its input came from a pixel grid or a sentence; it receives a weighted sum and returns a number, and the network's later layers interpret that number according to the task.

Image reconstruction is a third use, and it differs from classification in what counts as success. In classification the network must pick the right label; in reconstruction it must reproduce an image closely, and the measure of closeness is typically the peak signal-to-noise ratio, which compares the rebuilt image to the original. The same comparison of activation functions evaluated reconstruction alongside classification, and found that the hyperbolic tangent gave the highest peak signal-to-noise ratio on that task while the rectified unit led on the classification tasks.⁠[4] The split is instructive: a function that compresses its output into a bounded range suits the job of reproducing a signal whose values are themselves bounded, while a function that passes positive values through unchanged suits the job of separating categories.

A more recent use pushes the activation into a different kind of network altogether. An implicit neural representation is a network that stores a signal not as a grid of samples but as a function: given a coordinate, the network returns the value of the image, sound, or field at that coordinate. Networks built with periodic activation functions, called sinusoidal representation networks, were proposed for exactly this, and were demonstrated on images, wavefields, video, and sound, together with their derivatives. The reason a periodic shape suits the job is that such a signal is often defined as the solution to a differential equation, where the derivatives carry as much meaning as the values, and the earlier architectures for implicit representations were incapable of modeling signals with fine detail and failed to represent a signal's derivatives.⁠[9] A sine is infinitely differentiable and its derivatives are themselves sines, so the network's output can be differentiated as often as the problem demands.

That property carries the function into physics-informed models, where the network is trained not only to match data but to satisfy an equation. The same work shows sinusoidal networks solving boundary value problems including particular Eikonal equations, which yield signed distance functions, the Poisson equation, and the Helmholtz and wave equations.⁠[9] In such a model the activation is doing double duty: it shapes the network's approximation of the field, and its smoothness is what allows the derivatives in the equation to be computed at all.

The function also turns up in hardware, where the question becomes how to produce the nonlinearity physically rather than numerically. An all-optical neural network has been demonstrated in which the linear operations are programmed by spatial light modulators and Fourier lenses, while the optical nonlinear activation functions are realized through electromagnetically induced transparency in laser-cooled atoms. The same scheme was used to classify the ordered and disordered phases of a statistical Ising model, and the authors note that because the errors from different optical neurons are independent, the system could scale to a larger size while the final error stays at roughly the level of a single neuron.⁠[12] A separate design realizes a single optical neuron with a logistic sigmoid activation, produced by a deeply saturated differentially biased semiconductor optical amplifier interferometer followed by a second amplifier acting through cross-gain modulation; its transfer function was measured and fitted almost perfectly by a logistic sigmoid, and the neuron was shown to threshold a sequence of pulses at four different weighted-and-summed power levels.⁠[13] In both cases the activation is no longer a line of code but a physical response curve, and the design problem becomes making that curve match the shape the network needs.

What ties these settings together is that the activation is always the point where a linear tally becomes something else. Whether the tally comes from a convolution over pixels, a projection of word vectors, a coordinate fed into an implicit representation, or a sum of optical power levels, the function is what turns it into a signal the next stage can use. The settings differ in which property of that transformation matters most: staying alive across the input range for expression recognition, boundedness for reconstruction, differentiability for physics, and physical realizability for optics.

The activation travels with the architecture: the same small nonlinear rule serves vision, text, signal representation, and optical hardware, with the setting deciding which of its properties matters most.

Research

Evidence on how much the choice matters

The question of whether the activation function actually changes outcomes, or merely changes the arithmetic on the way to the same result, has been put to direct test. The cleanest way to ask it is to hold everything else fixed: same architecture, same data, same training procedure, same number of trials, and vary only the function. A 2018 comparison did exactly that, running ReLU, tanh and sigmoid across image classification, text classification and image reconstruction, with ten independent randomized trials per condition and a non-parametric Kruskal-Wallis test to judge whether the differences among them were larger than chance. The answer was that they were: the study reports a statistically significant performance variance among the activations, which is the statistical way of saying the choice is not cosmetic.⁠[4]

The most dramatic difference was a failure rather than a margin. In the deep convolutional vision tasks, the sigmoid did not converge at all, a collapse the authors attribute to the vanishing gradient problem, and its accuracy came out equivalent to random probability.⁠[4] This is worth dwelling on because it is not a case of one function being a little worse than another. A network whose early layers receive almost no gradient cannot learn, and the sigmoid's saturation at both extremes is precisely what starves those layers. The same comparison found that ReLU and tanh both converged stably, while sigmoid failed to converge in the deep convolutional vision tasks.⁠[4]

Among the functions that did converge, the ranking depended on the task. ReLU achieved the highest mean accuracy and F1-score on both the image classification and the text classification tasks, while tanh produced the highest peak signal-to-noise ratio in image reconstruction.⁠[4] A single number cannot summarize which function is better, because the better function is the one whose shape suits what the network is being asked to produce.

That result sets the pattern for most of the comparative evidence: gains are real but conditional, and they tend to appear on particular tasks, particular depths, or particular architectures rather than across the board. The exponential linear unit is a case in point. Its designers report that ELU networks learn faster and generalize significantly better than ReLU and leaky ReLU networks once the network has more than five layers, and on CIFAR-100 they report that ELU networks significantly outperform ReLU networks equipped with batch normalization, while batch normalization does not improve the ELU networks. The same work reports that ELU networks were among the top ten reported results on CIFAR-10 and yielded the best published result on CIFAR-100 at the time, without multi-view evaluation or model averaging, and that on ImageNet ELU networks considerably sped up learning relative to a ReLU network of the same architecture, reaching under ten percent classification error for a single crop and single model.⁠[7]

Swish arrived by a different route and brought its own numbers. Rather than being designed by hand, it was found by a combination of exhaustive and reinforcement-learning-based search over candidate functions, and the best of the discovered forms, the input multiplied by the sigmoid of a scaled input, was then evaluated against the incumbent. The reported gains are modest in absolute terms but were measured on a demanding benchmark: simply replacing ReLU units with Swish units improved top-1 classification accuracy on ImageNet by 0.9 percent for Mobile NASNet-A and by 0.6 percent for Inception-ResNet-v2. The authors describe Swish as tending to work better than ReLU on deeper models across a number of challenging datasets, and they emphasize that its similarity to ReLU makes the substitution easy to make in an existing network.⁠[1]

Mish reports improvements of a similar order on detection and classification. On MS-COCO object detection, Mish outperformed leaky ReLU on YOLOv4 with a CSP-DarkNet-53 backbone by 2.1 percent in average precision, and on ImageNet-1k it outperformed ReLU on ResNet-50 in top-1 accuracy by roughly 1 percent, with all other network parameters and hyperparameters held constant.⁠[2] The controlled comparison is the point: the only thing changed was the function. The same work proposes a mechanism, arguing that the behavior of the function's first derivative acts as a regularizer that helps optimization in deep networks, and it situates Mish within the Swish family of functions.⁠[2]

A different line of work asks whether the function should be fixed at all. Instead of choosing a shape in advance, one approach makes the shape itself a learned quantity: a piecewise linear activation function is learned independently for each neuron using gradient descent, and with this adaptive function the authors report improving on deep architectures composed of static rectified linear units, achieving state-of-the-art performance on CIFAR-10 at 7.51 percent, CIFAR-100 at 30.83 percent, and a high-energy physics benchmark involving Higgs boson decay modes.⁠[3]

A related approach keeps a standard shape but scales it. Locally adaptive activation functions introduce a scalable parameter in each layer, or separately for every neuron, and optimize that parameter alongside the weights using a variant of stochastic gradient descent; adding an activation-slope-based recovery term to the loss further accelerates convergence and reduces training cost. The authors prove that under practical conditions on initialization and learning rate, gradient descent is not attracted to sub-optimal critical points or local minima in this scheme, and that its gradient dynamics cannot be reproduced by the base method with any adaptive learning rate. They further show that the adaptive methods accelerate convergence by implicitly multiplying conditioning matrices into the gradient of the base method, without explicitly computing the matrix or its product, and that different adaptive activation functions induce different implicit conditioning matrices.⁠[14]

Set against all of this is the fact that ReLU has been described as the most successful and widely-used activation function. The search that produced Swish notes that although various hand-designed alternatives to ReLU have been proposed, none have managed to replace it, because their gains have been inconsistent.⁠[1] The choice of activation function demonstrably matters, sometimes decisively, as when a saturating function prevents a deep network from learning at all; but which alternative is better depends on the task, the depth, and the architecture, and no single function has been shown to dominate across the range of problems that deep networks are asked to solve.

Comparative trials show the choice can decide whether a deep network learns at all, but among the functions that do learn, the winner changes with the task.

caption: On deep convolutional vision tasks, the sigmoid failed to converge while ReLU and tanh converged stably.

Risks and limits

Costs, failure modes and open problems

Every activation function is a compromise, and the compromises show up as specific failures during training. The most discussed is the one that afflicts the rectified unit on its negative side. Because the plain rectified function outputs exactly zero for any negative input, its derivative there is also exactly zero, and a unit whose weighted sum stays negative receives no gradient at all. It stops changing, and since its output is zero it contributes nothing to the layers above it either. The condition is sometimes called the dying neuron problem: the unit is not damaged, but it has been pushed into a region where learning cannot reach it, and it stays there.

Two neuron diagrams compare ReLU and leaky ReLU beside a sigmoid curve and a four-stage gradient multiplication chain.
ReLU and leaky ReLU respond differently to a negative weighted sum. A sigmoid curve and an illustrative chain of four slopes show how small derivatives shrink a backward gradient. View full-size image.Zero Slopes and Vanishing Gradients by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The failure is not hypothetical, and it is named plainly in applied work. A study of convolutional models for facial expression recognition singles out this property of the rectified unit, noting that because its derivative is always zero when the input is negative, the phenomenon of neuronal necrosis is likely to appear, and it treats that shortcoming as the motivation for designing a new piecewise function and comparing it against five common alternatives on two public expression databases.⁠[11] The remedy in that case is a shape whose negative branch retains some slope, so that a unit pushed below zero still has a direction to move in. The leaky and parametrized variants described earlier take the same approach, and the exponential linear unit's saturating negative floor is a third answer to the same problem.

Saturation is the second failure mode, and it is older than the rectified unit. A function that flattens at its extremes has a slope near zero in those regions, and a network trained by following slopes has nothing to follow once its units drift there. The consequence can be total: in the controlled comparison of ReLU, tanh and sigmoid, the sigmoid failed to converge in deep convolutional vision tasks because of the vanishing gradient problem and reached accuracies equivalent to random guessing, while the other two converged stably.⁠[4] The flat region does not merely slow learning; it can remove the signal that learning depends on.

The flat region can also hide dependencies that a first-order method cannot see. A training procedure that uses only first-order gradients can be blind to structure that lies across a saturated stretch, because the slope it would need to climb is invisible there. One response is to inject noise into the problematic parts of the function so that gradients flow even where the noiseless application would yield zero, letting the optimizer explore the boundary between the degenerate and well-behaved regions; the approach connects to simulated annealing when the noise is annealed down over training, and replacing saturating functions with noisy variants was found to help training in many contexts, yielding state-of-the-art or competitive results on different datasets and tasks, especially when training was most difficult.⁠[8] Noise here is not a defect to be suppressed but a deliberate cost paid to keep a dead region passable.

A third cost is arithmetic and memory. Some functions are cheap by construction: a rectified unit is a comparison against zero, and its derivative is a choice between one and zero. Others require an exponential, a hyperbolic tangent, or both composed together, and those operations are paid at every unit of every layer on every pass forward and backward. The cost is easy to underestimate because it does not appear in the accuracy figures, but it accumulates over a network with millions of units and over training runs that repeat the computation many times. The exponential linear unit's designers weighed exactly this trade, arguing that pushing mean activations toward zero speeds learning with lower computational complexity than the normalization step that would otherwise be needed to achieve the same centering.⁠[7] A function that buys accuracy with extra operations is only worth it if the accuracy gain exceeds what the same budget would buy elsewhere.

Set against these specific costs is a broader and less tractable problem: the gains from alternatives have been inconsistent. The search that produced Swish states the situation directly, noting that although various hand-designed alternatives to ReLU have been proposed, none have managed to replace it because their gains have been inconsistent.⁠[1] That is not a claim that the alternatives fail; it is a claim that their advantages do not generalize reliably from one setting to another, which makes the choice of function an empirical question that has to be settled anew for each architecture and dataset rather than a matter of applying a known best practice.

A newer cost arises when a network must be certified rather than merely trained. Robustness certification is the task of proving that a network's output cannot change by more than a bounded amount when its input is perturbed within some limit, and it is what allows a classifier to be trusted in settings where a wrong answer is expensive. Early methods exploited the piecewise linear nature of the rectified unit, which makes the bounds tractable to compute, and a general framework was introduced to certify networks with general activation functions by bounding a given function with linear and quadratic surrogates, handling ReLU, tanh, sigmoid and arctan among others, and adaptively selecting appropriate surrogates for each neuron activation to tighten the certified bound.⁠[15] The point for the present purpose is that a function's shape is not only a training decision. A shape that trains well may be hard to certify, and the machinery that proves a network safe has to be rebuilt around whatever curve the units actually use.

These costs do not point to a single verdict. The dying neuron argues for a live negative branch; saturation argues against a flat tail; arithmetic argues for simplicity; certification argues for shapes that can be bounded. The functions in use are different settlements of the same disputes, and the disputes are not closed.

Later developments

Search, adaptation and the road ahead

The functions described so far were designed by people who reasoned about slopes, saturation and the mean of a unit's output, then tested what they built. A different approach hands the design problem to a search procedure. Rather than proposing a shape and defending it, one line of work defines a space of candidate functions and lets an algorithm explore it, combining exhaustive enumeration with reinforcement learning to discover several novel forms. The best of the discovered functions, the input multiplied by the sigmoid of a scaled input, was named Swish, and its authors note that its simplicity and its similarity to the rectified unit make it easy to substitute into an existing network.⁠[1] The significance is methodological as much as numerical: the shape was found rather than argued for, which suggests the space of useful bends is larger than hand design had explored.

An input vector splits into value and gate branches that rejoin at a component-wise multiplication node with output vector [1, −2].
A gated linear unit multiplies a value projection by a sigmoid gate from a second projection of the same input. The example shows the gating operation for one sequence position. View full-size image.Two Projections Form a Gated Unit by Atlas Nova. Illustration generated with AI for this article and checked against its text.

A second line of work makes the shape a fitted quantity rather than a fixed one. Instead of choosing a curve in advance and applying it everywhere, a piecewise linear activation function can be learned independently for each neuron using gradient descent, so that every unit carries its own bend and adjusts it during training. With this adaptive arrangement the authors report improving on deep architectures built from static rectified linear units, reaching state-of-the-art performance on CIFAR-10 at 7.51 percent, CIFAR-100 at 30.83 percent, and a high-energy physics benchmark involving Higgs boson decay modes.⁠[3] The idea reframes the question the earlier sections kept returning to. If the best shape varies from neuron to neuron and layer to layer, then imposing one function across a whole network is a constraint, and removing it buys something.

A related approach keeps a conventional shape but scales it. Locally adaptive activation functions introduce a scalable parameter in each layer, or separately for every neuron, and optimize that parameter alongside the weights using a variant of stochastic gradient descent; an activation-slope-based recovery term added to the loss accelerates convergence further and reduces training cost. The same work proves that under practical conditions on initialization and learning rate, gradient descent is not attracted to sub-optimal critical points or local minima in this scheme, and that the gradient dynamics of the proposed method is not achievable by base methods with any adaptive learning rates. It also shows that the adaptive methods speed convergence by implicitly multiplying conditioning matrices into the gradient of the base method, without computing the matrix or its product explicitly, and that different adaptive functions induce different implicit conditioning matrices.⁠[14] Adaptation, on this account, changes the geometry of optimization rather than merely adding parameters to fit.

The most recent setting to reshape the question is the Transformer, a sequence model whose feed-forward sublayers transform each position independently. Gated linear units combine two linear projections by taking their component-wise product, with one of the projections first passed through a sigmoid, and variants are possible that substitute different nonlinear functions, or even linear ones, in place of that sigmoid. Testing these variants in the feed-forward sublayers of the Transformer, one study finds that some of them yield quality improvements over the typically used ReLU or GELU activations.⁠[16] The finding is modest and scoped to that architecture, but it illustrates a pattern: the function interacts with the block it sits in, and a substitution that helps in one kind of network need not help in another.

That pattern is where the subject currently rests. The comparative record covered earlier showed real but conditional gains, and the search and adaptation work adds a further twist, since a function can now be discovered, learned per neuron, or scaled per layer rather than selected from a menu. What has not emerged is a rule mapping architecture to function. The evidence supports treating the choice as an empirical question, settled by controlled comparison on the task and network at hand, and the tools for settling it have grown considerably more powerful than the hand-designed alternatives that first challenged the rectified unit.

Automatic search, per-neuron learning and per-layer scaling have widened the space of usable shapes; which shape suits which architecture remains an open, empirical question.

Key studies

YearStudySampleDesignFinding
2014Agostinelli et al.⁠[3]adaptive per-neuron activation learned by gradient descentThe adaptive activation reached 7.51% error on CIFAR-10 and 30.83% on CIFAR-100.
2015Clevert et al.⁠[7]comparison of exponential linear units with ReLU and leaky ReLU networksELU networks learned faster and generalized better than ReLU and leaky ReLU networks with more than 5 layers, reaching less than 10% classification error on ImageNet for a single crop, single model network.
2016Gülçehre et al.⁠[8]not stated in the abstract; several datasets and tasks including curriculum learning settingsnoisy activation functions with injected noiseSwapping saturating activation functions for noisy versions aided training in many settings, with results that were state-of-the-art or competitive on several datasets and tasks.
2017Ramachandran et al.⁠[1]automated search for activation functions plus empirical evaluationReplacing ReLU units with Swish units improved top-1 accuracy on ImageNet by 0.9% for Mobile NASNet-A and by 0.6% for Inception-ResNet-v2.
2018Agarap⁠[4]10 independent randomized trials with the Kruskal-Wallis H testSigmoid failed to converge in deep convolutional vision tasks, while ReLU gave the highest mean accuracy and F1-score on image and text classification.
2018Zhang et al.⁠[15]certification framework called CROWN for bounding adversarial distortion of networks with general activation functionsCROWN improved certified lower bounds over Fast-Lin on ReLU networks at comparable computational efficiency and also worked on tanh, sigmoid and arctan networks.
2019Misra⁠[2]benchmark comparison of Mish against other activation functionsMish beat Leaky ReLU on YOLOv4 by 2.1% in average precision on MS-COCO and ReLU on ResNet-50 by about 1% in top-1 accuracy on ImageNet-1k.
2019Mourgias-Alexandris et al.⁠[13]experimental and theoretical analysis of an all-optical neuronThe optical transfer function fitted a logistic sigmoid almost perfectly and demonstrated successful thresholding over the pulse sequence.
2019Zuo et al.⁠[12]experimental demonstration of an all-optical neural networkThe network used nonlinear activation functions realized with electromagnetically induced transparency in laser-cooled atoms and successfully classified the two phases.
2020Wang et al.⁠[11]comparison of five common activation functions plus a new piecewise function in a convolutional neural networkThe network using the new piecewise activation function performed better than most state-of-the-art activation functions.
2020Jagtap et al.⁠[14]layer-wise and neuron-wise adaptive activation slopes with a slope recovery termThe adaptive methods accelerated convergence and reduced training cost, and the authors proved gradient descent is not attracted to sub-optimal critical points under practical conditions.
2020Shazeer⁠[16]comparison of gated linear unit variants against ReLU and GELUIn the feed-forward sublayers of a Transformer model, certain gated linear unit variants performed better than the ReLU or GELU activations usually used there.

See also

References

  1. Ramachandran, P., Zoph, B., & Le, Q. V. (2017). Searching for Activation Functions. arXiv. doi:10.48550/arxiv.1710.05941 Free full text
  2. Misra, D. (2019). Mish: A Self Regularized Non-Monotonic Activation Function. arXiv. doi:10.48550/arxiv.1908.08681 Free full text
  3. Agostinelli, F., Hoffman, M. D., Sadowski, P., & Baldi, P. (2014). Learning Activation Functions to Improve Deep Neural Networks. arXiv. doi:10.48550/arxiv.1412.6830 Free full text
  4. Agarap, A. F. (2018). Deep Learning using Rectified Linear Units (ReLU). arXiv. doi:10.48550/arxiv.1803.08375 Free full text
  5. Sharma, S., Sharma, S., & Athaiya, A. (2020). Activation functions in neural networks. International Journal of Engineering Applied Sciences and Technology, 04(12), 310-316. doi:10.33564/ijeast.2020.v04i12.054
  6. Nwankpa, C. E., Ijomah, W., Gachagan, A., & Marshall, S. (2018). Activation Functions: Comparison of trends in Practice and Research for Deep Learning. arXiv. doi:10.48550/arxiv.1811.03378 Free full text
  7. Clevert, D. A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs). arXiv. doi:10.48550/arxiv.1511.07289 Free full text
  8. Gülçehre, Ç., Moczulski, M., Denil, M., & Bengio, Y. (2016). Noisy Activation Functions. arXiv. doi:10.48550/arxiv.1603.00391 Free full text
  9. Sitzmann, V., Martel, J., Bergman, A. W., Lindell, D. B., & Wetzstein, G. (2020). Implicit Neural Representations with Periodic Activation Functions. arXiv. doi:10.48550/arxiv.2006.09661 Free full text
  10. Krichen, M. (2023). Convolutional Neural Networks: A Survey. Computers, 12(8), 151. doi:10.3390/computers12080151
  11. Wang, Y., Li, Y., Song, Y., & Rong, X. (2020). The Influence of the Activation Function in a Convolution Neural Network Model of Facial Expression Recognition. Applied Sciences, 10(5), 1897. doi:10.3390/app10051897
  12. Zuo, Y., Li, B., Zhao, Y., Jiang, Y., Chen, Y. C., Chen, P., Jo, G. B., Liu, J., & Du, S. (2019). All-optical neural network with nonlinear activation functions. Optica, 6(9), 1132. doi:10.1364/optica.6.001132
  13. Mourgias-Alexandris, G., Tsakyridis, A., Passalis, N., Tefas, A., Vyrsokinos, K., & Pleros, N. (2019). An all-optical neuron with sigmoid activation function. Optics Express, 27(7), 9620. doi:10.1364/oe.27.009620
  14. Jagtap, A. D., Kawaguchi, K., & Em Karniadakis, G. (2020). Locally adaptive activation functions with slope recovery for deep and physics-informed neural networks. Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences, 476(2239), 20200334. doi:10.1098/rspa.2020.0334
  15. Zhang, H., Weng, T. W., Chen, P., Hsieh, C., & Daniel, L. (2018). Efficient Neural Network Robustness Certification with General Activation Functions. arXiv. doi:10.48550/arxiv.1811.00866 Free full text
  16. Shazeer, N. (2020). GLU Variants Improve Transformer. arXiv. doi:10.48550/arxiv.2002.05202 Free full text

Cite this page: Atlas Nova editors. (2026). Activation function. Atlas Nova. https://velocer.io/atlas/activation-functions/