Rectifier (neural networks)

From testwiki
Jump to navigation Jump to search

Template:Short description Template:Machine learning

Plot of the ReLU (blue) and GELU (green) functions near x = 0

In the context of artificial neural networks, the rectifier or ReLU (rectified linear unit) activation function[1][2] is an activation function defined as the non-negative part of its argument, i.e., the ramp function:

ReLU(x)=x+=max(0,x)=x+|x|2={xif x>0,0x0

where x is the input to a neuron. This is analogous to half-wave rectification in electrical engineering.

ReLU is one of the most popular activation functions for artificial neural networks,[3] and finds application in computer vision[4] and speech recognition[5][6] using deep neural nets and computational neuroscience.[7][8][9]

It was first used by Alston Householder in 1941 as a mathematical abstraction of biological neural networks.[10] It was introduced by Kunihiko Fukushima in 1969 in the context of visual feature extraction in hierarchical neural networks.[11][12] It was later argued that it has strong biological motivations and mathematical justifications.[13][14] In 2011,[4] ReLU activation enabled training deep supervised neural networks without unsupervised pre-training, compared to the widely used activation functions prior to 2011, e.g., the logistic sigmoid (which is inspired by probability theory; see logistic regression) and its more practical[15] counterpart, the hyperbolic tangent.

Template:TOC limit

Advantages

Advantages of ReLU include:

  • Sparse activation: for example, in a randomly initialized network, only about 50% of hidden units are activated (i.e. have a non-zero output).
  • Better gradient propagation: fewer vanishing gradient problems compared to sigmoidal activation functions that saturate in both directions.[4]
  • Efficiency: only requires comparison and addition.
  • Scale-invariant (homogeneous):
max(0,ax)=amax(0,x) for a0.

Potential problems

Possible downsides can include:

  • Non-differentiability at zero (however, it is differentiable anywhere else, and the value of the derivative at zero can be chosen to be 0 or 1 arbitrarily).
  • Not zero-centered: ReLU outputs are always non-negative. This can make it harder for the network to learn during backpropagation, because gradient updates tend to push weights in one direction (positive or negative). Batch normalization can help address this.Template:Citation needed
  • ReLU is unbounded.
  • Template:AnchorDying ReLU: ReLU neurons can sometimes be pushed into states in which they become inactive for essentially all inputs. In this state, no gradients flow backward through the neuron, and so the neuron becomes stuck in a perpetually inactive state (it "dies"). This is a form of the vanishing gradient problem. In some cases, large numbers of neurons in a network can become stuck in dead states, effectively decreasing the model capacity and potentially even halting the learning process. This problem typically arises when the learning rate is set too high. It may be mitigated by using "leaky" ReLU instead, where a small positive slope is assigned for x<0. However, depending on the task, performance may be reduced.

Variants

Piecewise-linear variants

Leaky ReLU allows a small, positive gradient when the unit is inactive,[6] helping to mitigate the vanishing gradient problem. This gradient is defined by a parameter α, typically set to 0.01–0.3.[16][17]

f(x)={xx>0,αxx0,f(x)={1x>0,αx0.

Parametric ReLU (PReLU) takes this idea further by making α a learnable parameter along with the other network parameters.[18]

Note that for α1, this is equivalent to

f(x)=max(x,αx)

and thus has a relation to "maxout" networks.[18]

Concatenated ReLU (CReLU) preserves positive and negative phase information:[19]

f(x)=[ReLU(x),ReLU(x)].

Other non-linear variants

Gaussian-error linear unit (GELU)

GELU is a smooth approximation to the rectifier:

f(x)=xΦ(x),
f(x)=xΦ(x)+Φ(x)

where Φ(x)=P(Xx) is the cumulative distribution function of the standard normal distribution.

This activation function is illustrated in the figure at the start of this article. It has a "bump" to the left of x < 0 and serves as the default activation for models such as BERT.[20]

SiLU

Template:Main The SiLU (sigmoid linear unit) or swish function[21] is another smooth approximation which uses the sigmoid function, first introduced in the GELU paper:[20]

f(x)=xsigmoid(x),
f(x)=xsigmoid(x)+sigmoid(x)

Softplus

Template:Main A smooth approximation to the rectifier is the analytic function

f(x)=ln(1+ex),f(x)=ex1+ex=11+ex

which is called the softplus[22][4] or SmoothReLU function.[23] For large negative x it is roughly ln1, so just above 0, while for large positive x it is roughly ln(ex), so just above x.

This function can be approximated as:

ln(1+ex){ln2,x=0,x1ex/ln2,x0

By making the change of variables x=yln(2), this is equivalent to

log2(1+2y){1,y=0,y1ey,y0

A sharpness parameter k may be included:

f(x)=ln(1+ekx)k,f(x)=ekx1+ekx=11+ekx

The derivative of softplus is the logistic function.

The logistic sigmoid function is a smooth approximation of the derivative of the rectifier, the Heaviside step function.

The multivariable generalization of single-variable softplus is the LogSumExp with the first argument set to zero:

LSE0+(x1,,xn):=LSE(0,x1,,xn)=ln(1+ex1++exn)

The LogSumExp function is

LSE(x1,,xn)=ln(ex1++exn)

and its gradient is the softmax; the softmax with the first argument set to zero is the multivariable generalization of the logistic function. Both LogSumExp and softmax are used in machine learning.

ELU

Exponential linear units try to make the mean activations closer to zero, which speeds up learning. It has been shown that ELUs can obtain higher classification accuracy than ReLUs.[24]

f(x)={xx>0,α(ex1)x0f(x)={1x>0,αexx0

In these formulas, α is a hyperparameter to be tuned with the constraint α0.

Given the same interpretation of α, ELU can be viewed as a smoothed version of a shifted ReLU (SReLU), which has the form f(x)=max(α,x).

Mish

The mish function can also be used as a smooth approximation of the rectifier.[21] It is defined as

f(x)=xtanh(softplus(x)),

where tanh(x) is the hyperbolic tangent, and softplus(x) is the softplus function.

Mish is non-monotonic and self-gated.[25] It was inspired by Swish, itself a variant of ReLU.[25]

Squareplus

Squareplus[26] is the function

f(x)=x+x2+b2

where b0 is a hyperparameter that determines the "size" of the curved region near x=0. (For example, letting b=0 yields ReLU, and letting b=4 yields the metallic mean function.) Squareplus shares many properties with softplus: It is monotonic, strictly positive, approaches 0 as x, approaches the identity as x+, and is C smooth. However, squareplus can be computed using only algebraic functions, making it well-suited for settings where computational resources or instruction sets are limited. Additionally, squareplus requires no special consideration to ensure numerical stability when x is large.

See also

References

Template:Reflist

Template:Artificial intelligence navbox