Activation function
{{Short description|Artificial neural network node function}}
{{About||the formalism used to approximate the influence of an extracellular electrical field on neurons|activating function|a linear system’s transfer function|transfer function}}
{{Machine learning}}
The activation function of a node in an artificial neural network is a function that calculates the output of the node based on its individual inputs and their weights. Nontrivial problems can be solved using only a few nodes if the activation function is nonlinear.{{Cite web|url=http://didattica.cs.unicam.it/lib/exe/fetch.php?media=didattica:magistrale:kebi:ay_1718:ke-11_neural_networks.pdf|title=Neural Networks, p. 7|last=Hinkelmann|first=Knut|website=University of Applied Sciences Northwestern Switzerland|access-date=2018-10-06|archive-date=2018-10-06|archive-url=https://web.archive.org/web/20181006235506/http://didattica.cs.unicam.it/lib/exe/fetch.php?media=didattica:magistrale:kebi:ay_1718:ke-11_neural_networks.pdf|url-status=dead}}
Modern activation functions include the logistic (sigmoid) function used in the 2012 speech recognition model developed by Hinton et al;{{Cite journal |last1=Hinton |first1=Geoffrey |last2=Deng |first2=Li |last3=Deng |first3=Li |last4=Yu |first4=Dong |last5=Dahl |first5=George |last6=Mohamed |first6=Abdel-rahman |last7=Jaitly |first7=Navdeep |last8=Senior |first8=Andrew |last9=Vanhoucke |first9=Vincent |last10=Nguyen |first10=Patrick |last11=Sainath |first11=Tara|author11-link= Tara Sainath |last12=Kingsbury |first12=Brian |year=2012 |title=Deep Neural Networks for Acoustic Modeling in Speech Recognition |journal=IEEE Signal Processing Magazine |volume=29 |issue=6 |pages=82–97 |doi=10.1109/MSP.2012.2205597|s2cid=206485943 }} the ReLU used in the 2012 AlexNet computer vision model{{Cite journal |last1=Krizhevsky |first1=Alex |last2=Sutskever |first2=Ilya |last3=Hinton |first3=Geoffrey E. |date=2017-05-24 |title=ImageNet classification with deep convolutional neural networks |url=https://dl.acm.org/doi/10.1145/3065386 |journal=Communications of the ACM |language=en |volume=60 |issue=6 |pages=84–90 |doi=10.1145/3065386 |issn=0001-0782}}{{Cite journal |last1=King Abdulaziz University |last2=Al-johania |first2=Norah |last3=Elrefaei |first3=Lamiaa |last4=Benha University |date=2019-06-30 |title=Dorsal Hand Vein Recognition by Convolutional Neural Networks: Feature Learning and Transfer Learning Approaches |url=http://www.inass.org/2019/2019063019.pdf |journal=International Journal of Intelligent Engineering and Systems |volume=12 |issue=3 |pages=178–191 |doi=10.22266/ijies2019.0630.19}} and in the 2015 ResNet model; and the smooth version of the ReLU, the GELU, which was used in the 2018 BERT model.{{Cite arXiv |eprint=1606.08415 |title=Gaussian Error Linear Units (GELUs) |last1=Hendrycks |first1=Dan |last2=Gimpel |first2=Kevin |year=2016 |class=cs.LG}}
Comparison of activation functions
Aside from their empirical performance, activation functions also have different mathematical properties:
; Nonlinear: When the activation function is non-linear, then a two-layer neural network can be proven to be a universal function approximator.{{Cite journal|author1-link=George Cybenko|last=Cybenko|first=G.|date=December 1989|title=Approximation by superpositions of a sigmoidal function|journal=Mathematics of Control, Signals, and Systems|language=en|volume=2|issue=4|pages=303–314|doi=10.1007/BF02551274|bibcode=1989MCSS....2..303C |s2cid=3958369|issn=0932-4194|url=https://hal.archives-ouvertes.fr/hal-03753170/file/Cybenko1989.pdf }} This is known as the Universal Approximation Theorem. The identity activation function does not satisfy this property. When multiple layers use the identity activation function, the entire network is equivalent to a single-layer model.
; Range: When the range of the activation function is finite, gradient-based training methods tend to be more stable, because pattern presentations significantly affect only limited weights. When the range is infinite, training is generally more efficient because pattern presentations significantly affect most of the weights. In the latter case, smaller learning rates are typically necessary.{{citation needed|date=January 2016}}
; Continuously differentiable: This property is desirable (ReLU is not continuously differentiable and has some issues with gradient-based optimization, but it is still possible) for enabling gradient-based optimization methods. The binary step activation function is not differentiable at 0, and it differentiates to 0 for all other values, so gradient-based methods can make no progress with it.{{cite book|url={{google books |plainurl=y |id=0tFmf_UKl7oC}}|title=Practical Mathematical Optimization: An Introduction to Basic Optimization Theory and Classical and New Gradient-Based Algorithms|last=Snyman|first=Jan|date=3 March 2005|publisher=Springer Science & Business Media|isbn=978-0-387-24348-1}}
These properties do not decisively influence performance, nor are they the only mathematical properties that may be useful. For instance, the strictly positive range of the softplus makes it suitable for predicting variances in variational autoencoders.
Mathematical details
The most common activation functions can be divided into three categories: ridge functions, radial functions and fold functions.
An activation function is saturating if . It is nonsaturating if it is . Non-saturating activation functions, such as ReLU, may be better than saturating activation functions, because they are less likely to suffer from the vanishing gradient problem.{{Cite journal |last1=Krizhevsky |first1=Alex |last2=Sutskever |first2=Ilya |last3=Hinton |first3=Geoffrey E. |date=2017-05-24 |title=ImageNet classification with deep convolutional neural networks |journal=Communications of the ACM |volume=60 |issue=6 |pages=84–90 |doi=10.1145/3065386 |s2cid=195908774 |issn=0001-0782|doi-access=free }}
= Ridge activation functions =
{{Main|Ridge function}}
Ridge functions are multivariate functions acting on a linear combination of the input variables. Often used examples include:{{Clarify|reason=what is a? what is v'? what is b?|date=November 2023}}
In biologically inspired neural networks, the activation function is usually an abstraction representing the rate of action potential firing in the cell.{{Cite journal|last1=Hodgkin|first1=A. L.|last2=Huxley|first2=A. F.|date=1952-08-28|title=A quantitative description of membrane current and its application to conduction and excitation in nerve |journal=The Journal of Physiology|volume=117|issue=4|pages=500–544 |pmc=1392413|pmid=12991237|doi=10.1113/jphysiol.1952.sp004764}} In its simplest form, this function is binary—that is, either the neuron is firing or not. Neurons also cannot fire faster than a certain rate, motivating sigmoid activation functions whose range is a finite interval.
The function looks like , where is the Heaviside step function.
If a line has a positive slope, on the other hand, it may reflect the increase in firing rate that occurs as input current increases. Such a function would be of the form .
=Radial activation functions =
{{Main|Radial function}}
A special class of activation functions known as radial basis functions (RBFs) are used in RBF networks. These activation functions can take many forms, but they are usually found as one of the following functions:
- Gaussian:
- Multiquadratics:
- Inverse multiquadratics:
- Polyharmonic splines
where is the vector representing the function center and and are parameters affecting the spread of the radius.
= Other examples =
Periodic functions can serve as activation functions. Usually the sinusoid is used, as any periodic function is decomposable into sinusoids by the Fourier transform.{{Cite journal |last1=Sitzmann |first1=Vincent |last2=Martel |first2=Julien |last3=Bergman |first3=Alexander |last4=Lindell |first4=David |last5=Wetzstein |first5=Gordon |date=2020 |title=Implicit Neural Representations with Periodic Activation Functions |url=https://proceedings.neurips.cc/paper/2020/hash/53c04118df112c13a8c34b38343b9c10-Abstract.html |journal=Advances in Neural Information Processing Systems |publisher=Curran Associates, Inc. |volume=33 |pages=7462–7473|arxiv=2006.09661 }}
Quadratic activation maps .{{Citation |last=Flake |first=Gary William |title=Square Unit Augmented Radially Extended Multilayer Perceptrons |date=1998 |work=Neural Networks: Tricks of the Trade |series=Lecture Notes in Computer Science |volume=1524 |pages=145–163 |editor-last=Orr |editor-first=Genevieve B. |url=https://link.springer.com/chapter/10.1007/3-540-49430-8_8 |access-date=2024-10-05 |place=Berlin, Heidelberg |publisher=Springer |language=en |doi=10.1007/3-540-49430-8_8 |isbn=978-3-540-49430-0 |editor2-last=Müller |editor2-first=Klaus-Robert}}{{Cite journal |last1=Du |first1=Simon |last2=Lee |first2=Jason |date=2018-07-03 |title=On the Power of Over-parametrization in Neural Networks with Quadratic Activation |url=https://proceedings.mlr.press/v80/du18a.html |journal=Proceedings of the 35th International Conference on Machine Learning |language=en |publisher=PMLR |pages=1329–1338|arxiv=1803.01206 }}
= Folding activation functions =
{{Main|Fold function}}
Folding activation functions are extensively used in the pooling layers in convolutional neural networks, and in output layers of multiclass classification networks. These activations perform aggregation over the inputs, such as taking the mean, minimum or maximum. In multiclass classification the softmax activation is often used.
= Table of activation functions =
The following table compares the properties of several activation functions that are functions of one fold {{mvar|x}} from the previous layer or layers:
class="wikitable sortable bs-exportable exportable" |
Name
! class="unsortable" | Plot ! Function, ! Derivative of , ! Range |
---|
Identity
| File:Activation identity.svg | | | | |
Binary step
| File:Activation binary step.svg | 0 & \text{if } x < 0\\ 1 & \text{if } x \ge 0 \end{cases} | | | |
Logistic, sigmoid, or soft{{nbsp}}step
| File:Activation logistic.svg | | | | |
Hyperbolic tangent (tanh)
| | | | |
Soboleva modified hyperbolic tangent (smht)
| | | | |
Softsign
| | |
|
|
|
|-
| Rectified linear unit (ReLU){{Citation|last1=Nair|first1=Vinod|last2=Hinton|first2=Geoffrey E.|date=2010|contribution=Rectified Linear Units Improve Restricted Boltzmann Machines|contribution-url=http://dl.acm.org/citation.cfm?id=3104322.3104425|title=27th International Conference on International Conference on Machine Learning|series=ICML'10|location=USA|publisher=Omnipress|pages=807–814|isbn=9781605589077}}
| File:Activation rectified linear.svg
|
(x)^+ \doteq {} &\begin{cases}
0 & \text{if } x \le 0\\
x & \text{if } x > 0
\end{cases} \\
= {} &\max(0,x) = x \textbf{1}_{x>0}
\end{align}
|
0 & \text{if } x < 0\\
1 & \text{if } x > 0
\end{cases}
|
|
|-
| Gaussian Error Linear Unit (GELU)
|
&\frac{1}{2} x \left(1 + \text{erf}\left(\frac{x}{\sqrt{2}}\right)\right) \\
{}={} &x\Phi(x)
\end{align} where is the gaussian error function.
| where is the probability density function of standard gaussian distribution.
|
|
|-
| Softplus{{Cite web|url=http://proceedings.mlr.press/v15/glorot11a/glorot11a.pdf|title=Deep sparse rectifier neural networks|last1=Glorot|first1=Xavier|last2=Bordes|first2=Antoine|date=2011|website=International Conference on Artificial Intelligence and Statistics|last3=Bengio|first3=Yoshua}}
| File:Activation softplus.svg
|
|
|
|
|-
| Exponential linear unit (ELU){{Cite arXiv|last1=Clevert|first1=Djork-Arné|last2=Unterthiner|first2=Thomas|last3=Hochreiter|first3=Sepp|date=2015-11-23|title=Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)|eprint=1511.07289 |class=cs.LG}}
|
\alpha\left(e^x - 1\right) & \text{if } x \le 0\\
x & \text{if } x > 0
\end{cases}
: with parameter
|
\alpha e^x & \text{if } x < 0 \\
1 & \text{if } x > 0
\end{cases}
|
|
C^1 & \text{if } \alpha = 1 \\
C^0 & \text{otherwise}
\end{cases}
|-
| Scaled exponential linear unit (SELU){{Cite journal |last1=Klambauer |first1=Günter |last2=Unterthiner |first2=Thomas |last3=Mayr |first3=Andreas |last4=Hochreiter |first4=Sepp |date=2017-06-08 |title=Self-Normalizing Neural Networks |journal=Advances in Neural Information Processing Systems |volume=30 |issue=2017 |arxiv=1706.02515}}
|
\alpha(e^x - 1) & \text{if } x < 0\\
x & \text{if } x \ge 0
\end{cases}
:with parameters and
|
\alpha e^x & \text{if } x < 0\\
1 & \text{if } x \ge 0
\end{cases}
|
|
|-
| Leaky rectified linear unit (Leaky ReLU){{cite journal |last1=Maas |first1=Andrew L. |last2=Hannun |first2=Awni Y. |last3=Ng |first3=Andrew Y. |s2cid=16489696 |title=Rectifier nonlinearities improve neural network acoustic models |journal=Proc. ICML |date=June 2013 |volume=30 |issue=1}}
|
0.01x & \text{if } x \le 0\\
x & \text{if } x > 0
\end{cases}
|
0.01 & \text{if } x < 0\\
1 & \text{if } x > 0
\end{cases}
|
|
|-
| Parametric rectified linear unit (PReLU){{Cite arXiv |last1=He |first1=Kaiming |last2=Zhang |first2=Xiangyu |last3=Ren |first3=Shaoqing |last4=Sun |first4=Jian |date=2015-02-06 |title=Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification |eprint=1502.01852 |class=cs.CV}}
|
\alpha x & \text{if } x < 0\\
x & \text{if } x \ge 0
\end{cases}
: with parameter
|
\alpha & \text{if } x < 0\\
1 & \text{if } x \ge 0
\end{cases}
|
|
|-
| Rectified Parametric Sigmoid Units (flexible, 5 parameters)
|
where
{{Citation
|first1=Abdourrahmane M.|last1=Atto|first2=Sylvie|last2=Galichet|first3=Dominique|last3=Pastor|first4=Nicolas|last4=Méger
|contribution = On joint parameterizations of linear and nonlinear functionals in neural networks
|contribution-url = https://doi.org/10.1016/j.neunet.2022.12.019
|title = Elsevier Pattern Recognition
|date = 2023
|volume=160 |pages=12–21 |doi=10.1016/j.neunet.2022.12.019 |pmid=36592526 }}
|
|
|
|-
| Sigmoid linear unit (SiLU, Sigmoid shrinkage,
{{Citation
|first1=Abdourrahmane M.|last1=Atto|first2=Dominique|last2=Pastor|first3=Grégoire|last3=Mercier
|contribution = Smooth sigmoid wavelet shrinkage for non-parametric estimation
|contribution-url = https://hal.archives-ouvertes.fr/hal-02136546/file/ICASSP_ATTO_2008.pdf
|title = 2008 IEEE International Conference on Acoustics, Speech and Signal Processing
|date = 2008
|pages=3265–3268 |doi=10.1109/ICASSP.2008.4518347|isbn=978-1-4244-1483-3 |s2cid=9959057}} SiL,{{Cite journal |arxiv = 1702.03118|title = Sigmoid-Weighted Linear Units for Neural Network Function Approximation in Reinforcement Learning|journal = Neural Networks |volume = 107|pages = 3–11|last1 = Elfwing|first1 = Stefan|last2 = Uchibe|first2 = Eiji|last3 = Doya|first3 = Kenji|year = 2018|pmid = 29395652|doi = 10.1016/j.neunet.2017.12.012|s2cid = 6940861}} or Swish-{{zwj}}1{{Cite arXiv |eprint = 1710.05941 |title = Searching for Activation Functions|last1 = Ramachandran|first1 = Prajit|last2 = Zoph|first2 = Barret|last3 = Le|first3 = Quoc V|year = 2017|class = cs.NE}})
|
|
|
|
|-
|Exponential Linear Sigmoid SquasHing (ELiSH){{Citation |last1=Basirat |first1=Mina |title=The Quest for the Golden Activation Function |date=2018-08-02 |arxiv=1808.00783 |last2=Roth |first2=Peter M.}}
|File:Elish_activation_function.png
|
\frac{e^x - 1}{1 + e^{-x}} & \text{if } x < 0 \\
\frac{x}{1+e^{-x}} & \text{if } x\geq 0
\end{cases}
|
|
|
|-
| Gaussian
| File:Activation gaussian.svg
|
|
|
|
|-
|
|
|
|
|
|}
The following table lists activation functions that are not functions of a single fold {{mvar|x}} from the previous layer or layers:
class="wikitable sortable" |
Name
! Equation, ! Derivatives, ! Range |
---|
Softmax
| for {{mvar|i}} = 1, …, {{mvar|J}} | {{ref|kronecker_delta}}{{ref|j}} | | |
Maxout{{Cite journal|last1=Goodfellow|first1=Ian J.|last2=Warde-Farley|first2=David|last3=Mirza|first3=Mehdi|last4=Courville|first4=Aaron|last5=Bengio|first5=Yoshua|year=2013|title=Maxout Networks|journal=JMLR Workshop and Conference Proceedings |volume=28|issue=3|pages=1319–1327|arxiv=1302.4389 }}
| | 1 & \text{if } j = \underset{i}{\operatorname{argmax}} \, x_i \\ 0 & \text{if } j \ne \underset{i}{\operatorname{argmax}} \, x_i \end{cases} | | |
:{{note|kronecker_delta}} Here, is the Kronecker delta.
:{{note|j}} For instance, could be iterating through the number of kernels of the previous neural network layer while iterates through the number of kernels of the current layer.
=Quantum activation functions =
{{Main|Quantum function}}
In quantum neural networks programmed on gate-model quantum computers, based on quantum perceptrons instead of variational quantum circuits, the non-linearity of the activation function can be implemented with no need of measuring the output of each perceptron at each layer. The quantum properties loaded within the circuit such as superposition can be preserved by creating the Taylor series of the argument computed by the perceptron itself, with suitable quantum circuits computing the powers up to a wanted approximation degree. Because of the flexibility of such quantum circuits, they can be designed in order to approximate any arbitrary classical activation function.{{cite journal|doi=10.1007/s11128-022-03466-0 |issn=1570-0755 |title=Quantum activation functions for quantum neural networks|year=2022|last1=Maronese |first1=Marco|last2=Destri |first2=Claudio|last3= Prati|first3=Enrico |journal= Quantum Information Processing |volume=21|issue=4|page=128 |arxiv=2201.03700|bibcode=2022QuIP...21..128M }}
See also
References
{{reflist|30em}}
Further reading
- {{Citation |last1=Kunc |first1=Vladimír |title=Three Decades of Activations: A Comprehensive Survey of 400 Activation Functions for Neural Networks |date=2024-02-14 |arxiv=2402.09092 |last2=Kléma |first2=Jiří}}
- {{cite arXiv |last1=Nwankpa |first1=Chigozie |title=Activation Functions: Comparison of trends in Practice and Research for Deep Learning |date=2018-11-08 |eprint=1811.03378 |last2=Ijomah |first2=Winifred |last3=Gachagan |first3=Anthony |last4=Marshall |first4=Stephen|class=cs.LG }}
- {{cite journal |last1=Dubey |first1=Shiv Ram |last2=Singh |first2=Satish Kumar |last3=Chaudhuri |first3=Bidyut Baran |year=2022 |title=Activation functions in deep learning: A comprehensive survey and benchmark |journal=Neurocomputing |publisher=Elsevier BV |volume=503 |pages=92–108 |doi=10.1016/j.neucom.2022.06.111 |issn=0925-2312 |doi-access=free|arxiv=2109.14545 }}
{{Artificial intelligence navbox}}