Open main menu

Wikipedia β

Backpropagation is a method used in artificial neural networks to calculate the error contribution of each neuron after a batch of data (e.g. in image recognition, multiple images) is processed. This is used by an enveloping optimization algorithm to adjust the weight of each neuron, completing the learning process for that case.

Technically it calculates the gradient of the loss function. It is commonly used in the gradient descent optimization algorithm. It is also called backward propagation of errors, because the error is calculated at the output and distributed back through the network layers.

Backpropagation requires a known, desired output for each input value—it is therefore considered to be a supervised learning method (although it is used in some unsupervised networks such as autoencoders).

Backpropagation is a generalization of the delta rule to multi-layered feedforward networks, made possible by using the chain rule to iteratively compute gradients for each layer. The backpropagation algorithm has been repeatedly rediscovered and is a special case of a more general technique called automatic differentiation in reverse accumulation mode. It is closely related to the Gauss–Newton algorithm, and is part of continuing research in neural backpropagation.

Backpropagation can be used with any gradient-based optimizer, such as L-BFGS or truncated Newton[citation needed][clarification needed].

Backpropagation is sometimes referred to as deep learning,[1] a term used to describe neural networks with more than one hidden layer.[2]

Contents

MotivationEdit

The goal of any supervised learning algorithm is to find a function that best maps a set of inputs to their correct output. An example would be a classification task, where the input is an image of an animal, and the correct output is the name of the animal.

The motivation for backpropagation is to train a multi-layered neural network such that it can learn the appropriate internal representations to allow it to learn any arbitrary mapping of input to output.[3]

Loss functionEdit

Sometimes referred to as the cost function or error function (not to be confused with the Gauss error function), the loss function is a function that maps values of one or more variables onto a real number intuitively representing some "cost" associated with those values. For backpropagation, the loss function calculates the difference between the network output and its expected output, after a case propagates through the network.

AssumptionsEdit

Two assumptions must be made about the form of the error function.[4] The first is that it can be written as an average   over error functions  , for individual training examples,  . The reason for this assumption is that the backpropagation algorithm calculates the gradient of the error function for a single training example, which needs to be generalized to the overall error function. The second assumption is that it can be written as a function of the outputs from the neural network.

Example loss functionEdit

Let   be vectors in  .

Select an error function   measuring the difference between two outputs.

The standard choice is  ,

the square of the Euclidean distance between the vectors   and  .

The factor of   conveniently cancels the exponent when the error function is subsequently differentiated.

The error function over   training examples can be written as an average:

 
And the partial derivative with respect to the outputs:
 

OptimizationEdit

The optimization algorithm repeats a two phase cycle, propagation and weight update. When an input vector is presented to the network, it is propagated forward through the network, layer by layer, until it reaches the output layer. The output of the network is then compared to the desired output, using a loss function. The resulting error value is calculated for each of the neurons in the output layer. The error values are then propagated from the output back through the network, until each neuron has an associated error value that reflects its contribution to the original output.

Backpropagation uses these error values to calculate the gradient of the loss function. In the second phase, this gradient is fed to the optimization method, which in turn uses it to update the weights, in an attempt to minimize the loss function.

AlgorithmEdit

Let   be a neural network with   connections,   inputs, and   outputs.

Below,   will denote vectors in  ,   vectors in  , and   vectors in  . These are called inputs, outputs and weights respectively.

The neural network corresponds to a function   which, given a weight  , maps an input   to an output  .

The optimization takes as input a sequence of training examples   and produces a sequence of weights   starting from some initial weight  , usually chosen at random.

These weights are computed in turn: first compute   using only   for  . The output of the algorithm is then  , giving us a new function  . The computation is the same in each step, hence only the case   is described.

Calculating   from   is done by considering a variable weight   and applying gradient descent to the function   to find a local minimum, starting at  .

This makes   the minimizing weight found by gradient descent.

Algorithm in codeEdit

To implement the algorithm above, explicit formulas are required for the gradient of the function   where the function is .

The learning algorithm can be divided into two phases: propagation and weight update.

Phase 1: propagationEdit

Each propagation involves the following steps:

  1. Propagation forward through the network to generate the output value(s)
  2. Calculation of the cost (error term)
  3. Propagation of the output activations back through the network using the training pattern target in order to generate the deltas (the difference between the targeted and actual output values) of all output and hidden neurons.

Phase 2: weight updateEdit

For each weight, the following steps must be followed:

  1. The weight's output delta and input activation are multiplied to find the gradient of the weight.
  2. A ratio (percentage) of the weight's gradient is subtracted from the weight.

This ratio (percentage) influences the speed and quality of learning; it is called the learning rate. The greater the ratio, the faster the neuron trains, but the lower the ratio, the more accurate the training is. The sign of the gradient of a weight indicates whether the error varies directly with, or inversely to, the weight. Therefore, the weight must be updated in the opposite direction, "descending" the gradient.

Learning is repeated (on new batches) until the network performs adequately.

PseudocodeEdit

The following is pseudocode for a stochastic gradient descent algorithm for training a three-layer network (only one hidden layer):

  initialize network weights (often small random values)
  do
     forEach training example named ex
        prediction = neural-net-output(network, ex)  // forward pass
        actual = teacher-output(ex)
        compute error (prediction - actual) at the output units
        compute   for all weights from hidden layer to output layer  // backward pass
        compute   for all weights from input layer to hidden layer   // backward pass continued
        update network weights // input layer not modified by error estimate
  until all examples classified correctly or another stopping criterion satisfied
  return the network

The lines labeled "backward pass" can be implemented using the backpropagation algorithm, which calculates the gradient of the error of the network regarding the network's modifiable weights.[5]

IntuitionEdit

Learning as an optimization problemEdit

To understand the mathematical derivation of the backpropagation algorithm, it helps to first develop some intuitions about the relationship between the actual output of a neuron and the correct output for a particular training case. Consider a simple neural network with two input units, one output unit and no hidden units. Each neuron uses a linear output[note 1] that is the weighted sum of its input.

 
A simple neural network with two input units and one output unit

Initially, before training, the weights will be set randomly. Then the neuron learns from training examples, which in this case consists of a set of tuples   where   and   are the inputs to the network and t is the correct output (the output the network should eventually produce given those inputs). The initial network, given   and  , will compute an output y that likely differs from t (given random weights). A common method for measuring the discrepancy between the expected output t and the actual output y is the squared error measure:

 

where E is the discrepancy or error.

As an example, consider the network on a single training case:  , thus the input   and   are 1 and 1 respectively and the correct output, t is 0. Now if the actual output y is plotted on the horizontal axis against the error E on the vertical axis, the result is a parabola. The minimum of the parabola corresponds to the output y which minimizes the error E. For a single training case, the minimum also touches the horizontal axis, which means the error will be zero and the network can produce an output y that exactly matches the expected output t. Therefore, the problem of mapping inputs to outputs can be reduced to an optimization problem of finding a function that will produce the minimal error.

 
Error surface of a linear neuron for a single training case.

However, the output of a neuron depends on the weighted sum of all its inputs:

 

where   and   are the weights on the connection from the input units to the output unit. Therefore, the error also depends on the incoming weights to the neuron, which is ultimately what needs to be changed in the network to enable learning. If each weight is plotted on a separate horizontal axis and the error on the vertical axis, the result is a parabolic bowl. For a neuron with k weights, the same plot would require an elliptic paraboloid of   dimensions.

 
Error surface of a linear neuron with two input weights

One commonly used algorithm to find the set of weights that minimizes the error is gradient descent. Backpropagation is then used to calculate the steepest descent direction.

DerivationEdit

The gradient descent method involves calculating the derivative of the squared error function with respect to the weights of the network. This is normally done using backpropagation. Assuming one output neuron,[note 2] the squared error function is:

 

where

  is the squared error,
  is the target output for a training sample, and
  is the actual output of the output neuron.

The factor of   is included to cancel the exponent when differentiating. Later, the expression will be multiplied with an arbitrary learning rate, so that it doesn't matter if a constant coefficient is introduced now.

For each neuron  , its output   is defined as

 

The input   to a neuron is the weighted sum of outputs   of previous neurons. If the neuron is in the first layer after the input layer, the   of the input layer are simply the inputs   to the network. The number of input units to the neuron is  . The variable   denotes the weight between neurons   and  .

The activation function   is non-linear and differentiable. A commonly used activation function is the logistic function:

 

which has a convenient derivative of:

 

Finding the derivative of the errorEdit

Calculating the partial derivative of the error with respect to a weight   is done using the chain rule twice:

 

In the last factor of the right-hand side of the above, only one term in the sum   depends on  , so that

 

If the neuron is in the first layer after the input layer,   is just  .

The derivative of the output of neuron   with respect to its input is simply the partial derivative of the activation function (assuming here that the logistic function is used):

 

This is the reason why backpropagation requires the activation function to be differentiable.

The first factor is straightforward to evaluate if the neuron is in the output layer, because then   and

 

However, if   is in an arbitrary inner layer of the network, finding the derivative   with respect to   is less obvious.

Considering   as a function of the inputs of all neurons   receiving input from neuron  ,

 

and taking the total derivative with respect to  , a recursive expression for the derivative is obtained:

 

Therefore, the derivative with respect to   can be calculated if all the derivatives with respect to the outputs   of the next layer – the one closer to the output neuron – are known.

Putting it all together:

 

with

 

To update the weight   using gradient descent, one must choose a learning rate,  . The change in weight, which is added to the old weight, is equal to the product of the learning rate and the gradient, multiplied by  :

 

The   is required in order to update in the direction of a minimum, not a maximum, of the error function.

For a single-layer network, this expression becomes the Delta Rule.[6]

ExtensionEdit

The choice of learning rate   is important, since a high value can cause too strong a change, causing the minimum to be missed, while a too low learning rate slows the training unnecessarily.

Optimizations such as Quickprop are primarily aimed at speeding up error minimization; other improvements mainly try to increase reliability.

Adaptive learning rateEdit

In order to avoid oscillation inside the network such as alternating connection weights, and to improve the rate of convergence, refinements of this algorithm use an adaptive learning rate.[7]

InertiaEdit

By using a variable inertia term (Momentum)   the gradient and the last change can be weighted such that the weight adjustment additionally depends on the previous change. If the Momentum   is equal to 0, the change depends solely on the gradient, while a value of 1 will only depend on the last change.

Similar to a ball rolling down a mountain, whose current speed is determined not only by the current slope of the mountain but also by its own inertia, inertia can be added:

 
where:
  is the change in weight   in the connection of neuron   to neuron   at time  
  a learning rate ( 
  the error signal of neuron   and
  the output of neuron  , which is also an input of the current neuron (neuron  )
  the influence of the inertial term   (in  ). This corresponds to the weight change at the previous point in time.

Inertia depends on the current weight change   both from the current gradient of the error function (slope of the mountain, 1st summand), as well as from the weight change from the previous point in time (inertia, 2nd summand).

With inertia, the problems of getting stuck (in steep ravines and flat plateaus) are avoided. Since, for example, the gradient of the error function becomes very small in flat plateaus, inertia would immediately lead to a "deceleration" of the gradient descent. This deceleration is delayed by the addition of the inertia term so that a flat plateau can be escaped more quickly.

Modes of learningEdit

Two modes of learning are available: stochastic and batch. In stochastic learning, each input creates a weight adjustment. In batch learning weights are adjusted based on a batch of inputs, accumulating errors over the batch. Stochastic learning introduces "noise" into the gradient descent process, using the local gradient calculated from one data point; this reduces the chance of the network getting stuck in a local minima. However, batch learning typically yields a faster, more stable descent to a local minima, since each update is performed in the direction of the average error of the batch. A common compromise choice is to use "mini-batches", meaning small batches and with samples in each batch selected stochastically from the entire data set.

LimitationsEdit

 
Gradient descent can find the local minimum instead of the global minimum
  • Gradient descent with backpropagation is not guaranteed to find the global minimum of the error function, but only a local minimum; also, it has trouble crossing plateaux in the error function landscape. This issue, caused by the non-convexity of error functions in neural networks, was long thought to be a major drawback, but Yann LeCun et al. argue that in many practical problems, it is not.[8]
  • Backpropagation learning does not require normalization of input vectors; however, normalization could improve performance.[9]

HistoryEdit

According to various sources,[10][11][12][13][14] the basics of continuous backpropagation were derived in the context of control theory by Henry J. Kelley[15] in 1960 and by Arthur E. Bryson in 1961.[16] They used principles of dynamic programming. In 1962, Stuart Dreyfus published a simpler derivation based only on the chain rule.[17] Bryson and Ho described it as a multi-stage dynamic system optimization method in 1969.[18][19]

In 1970 Linnainmaa published the general method for automatic differentiation (AD) of discrete connected networks of nested differentiable functions.[20][21] This corresponds to backpropagation, which is efficient even for sparse networks.[13][14][22][23]

In 1973 Dreyfus used backpropagation to adapt parameters of controllers in proportion to error gradients.[24] In 1974 Werbos mentioned the possibility of applying this principle to artificial neural networks,[25] and in 1982 he applied Linnainmaa's AD method to neural networks in the way that is used today.[14][26]

In 1986 Rumelhart, Hinton and Williams showed experimentally that this method can generate useful internal representations of incoming data in hidden layers of neural networks.[3][27] In 1993, Wan was the first[13] to win an international pattern recognition contest through backpropagation.[28]

During the 2000s it fell out of favour, but returned in the 2010s, benefitting from cheap, powerful GPU-based computing systems.

In 2014, backpropagation was used to train a deep neural network for speech recognition.[29]

See alsoEdit

NotesEdit

  1. ^ One may notice that multi-layer neural networks use non-linear activation functions, so an example with linear neurons seems obscure. However, even though the error surface of multi-layer networks are much more complicated, locally they can be approximated by a paraboloid. Therefore, linear neurons are used for simplicity and easier understanding.
  2. ^ There can be multiple output neurons, in which case the error is the squared norm of the difference vector.

ReferencesEdit

  1. ^ A., Nielsen, Michael (2015). "Neural Networks and Deep Learning".  |chapter= ignored (help)
  2. ^ "Deep Networks: Overview - Ufldl". ufldl.stanford.edu. Retrieved 2017-08-04. 
  3. ^ a b Rumelhart, David E.; Hinton, Geoffrey E.; Williams, Ronald J. (8 October 1986). "Learning representations by back-propagating errors". Nature. 323 (6088): 533–536. doi:10.1038/323533a0. 
  4. ^ A., Nielsen, Michael (2015-01-01). "Neural Networks and Deep Learning". 
  5. ^ Paul J. Werbos (1994). The Roots of Backpropagation. From Ordered Derivatives to Neural Networks and Political Forecasting. New York, NY: John Wiley & Sons, Inc.
  6. ^ "The Back Propagation Algorithm" (PDF). p. 20.  |chapter= ignored (help)
  7. ^ Li, Y.; Fu, Y.; Li, H.; Zhang, S. W. (2009-06-01). "The Improved Training Algorithm of Back Propagation Neural Network with Self-adaptive Learning Rate". 2009 International Conference on Computational Intelligence and Natural Computing. 1: 73–76. doi:10.1109/CINC.2009.111. 
  8. ^ LeCun, Yann; Bengio, Yoshua; Hinton, Geoffrey (2015). "Deep learning". Nature. 521: 436–444. PMID 26017442. doi:10.1038/nature14539. 
  9. ^ Buckland, Matt; Collins, Mark. AI Techniques for Game Programming. ISBN 1-931841-08-X. 
  10. ^ DREYFUS, STUART E. (1990). "Artificial neural networks, back propagation, and the Kelley-Bryson gradient procedure". Journal of Guidance, Control, and Dynamics. 13 (5): 926–928. ISSN 0731-5090. doi:10.2514/3.25422. 
  11. ^ Stuart Dreyfus (1990). Artificial Neural Networks, Back Propagation and the Kelley-Bryson Gradient Procedure. J. Guidance, Control and Dynamics, 1990.
  12. ^ Mizutani, Eiji; Dreyfus, Stuart; Nishio, Kenichi (July 2000). "On derivation of MLP backpropagation from the Kelley-Bryson optimal-control gradient formula and its application." (PDF). Proceedings of the IEEE International Joint Conference on Neural Networks. 
  13. ^ a b c Schmidhuber, Jürgen (2015). "Deep learning in neural networks: An overview". Neural Networks. 61: 85–117. doi:10.1016/j.neunet.2014.09.003. 
  14. ^ a b c Schmidhuber, Jürgen (2015). "Deep Learning". Scholarpedia. 10 (11): 32832. doi:10.4249/scholarpedia.32832. 
  15. ^ Kelley, Henry J. (1960). "Gradient theory of optimal flight paths". Ars Journal. 30 (10): 947–954. doi:10.2514/8.5282. 
  16. ^ Arthur E. Bryson (1961, April). A gradient method for optimizing multi-stage allocation processes. In Proceedings of the Harvard Univ. Symposium on digital computers and their applications.
  17. ^ Dreyfus, Stuart. "The numerical solution of variational problems". Journal of Mathematical Analysis and Applications. 5 (1): 30–45. doi:10.1016/0022-247x(62)90004-5. 
  18. ^ Stuart Russell; Peter Norvig. Artificial Intelligence A Modern Approach. p. 578. The most popular method for learning in multilayer networks is called Back-propagation. 
  19. ^ Bryson, A. E.; Yu-Chi, Ho (1 January 1975). Applied Optimal Control: Optimization, Estimation and Control. CRC Press. ISBN 978-0-89116-228-5. 
  20. ^ Seppo Linnainmaa (1970). The representation of the cumulative rounding error of an algorithm as a Taylor expansion of the local rounding errors. Master's Thesis (in Finnish), Univ. Helsinki, 6–7.
  21. ^ Linnainmaa, Seppo (1976). "Taylor expansion of the accumulated rounding error". BIT Numerical Mathematics. 16 (2): 146–160. doi:10.1007/bf01931367. 
  22. ^ "Who Invented the Reverse Mode of Differentiation? - Semantic Scholar". www.semanticscholar.org. Retrieved 2017-08-04. 
  23. ^ Griewank, Andreas; Walther, Andrea (2008). Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, Second Edition. SIAM. ISBN 978-0-89871-776-1. 
  24. ^ Dreyfus, Stuart (1973). "The computational solution of optimal control problems with time lag". IEEE Transactions on Automatic Control. 18 (4): 383–385. doi:10.1109/tac.1973.1100330. 
  25. ^ Werbos, Paul John (1975). Beyond Regression: New Tools for Prediction and Analysis in the Behavioral Sciences. Harvard University. 
  26. ^ Werbos, Paul (1982). "Applications of advances in nonlinear sensitivity analysis". System modeling and optimization (PDF). Springer. pp. 762–770. 
  27. ^ Alpaydin, Ethem (2010). Introduction to Machine Learning. MIT Press. ISBN 978-0-262-01243-0. 
  28. ^ Wan, Eric A. (1993). "Time series prediction by using a connectionist network with internal delay lines" (PDF). SANTA FE INSTITUTE STUDIES IN THE SCIENCES OF COMPLEXITY-PROCEEDINGS. pp. 195–195. 
  29. ^ Abdel-Hamid, O.; Mohamed, A. r; Jiang, H.; Deng, L.; Penn, G.; Yu, D. (2014-10-01). "Convolutional Neural Networks for Speech Recognition". IEEE/ACM Transactions on Audio, Speech, and Language Processing. 22 (10): 1533–1545. ISSN 2329-9290. doi:10.1109/TASLP.2014.2339736. 

External linksEdit