Backpropagation through time

From HandWiki
Revision as of 18:31, 6 February 2024 by John Stpola (talk | contribs) (simplify)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Technique for training recurrent neural networks


Backpropagation through time (BPTT) is a gradient-based technique for training certain types of recurrent neural networks. It can be used to train Elman networks. The algorithm was independently derived by numerous researchers.[1][2][3]

Algorithm

BPTT unfolds a recurrent neural network through time.

The training data for a recurrent neural network is an ordered sequence of [math]\displaystyle{ k }[/math] input-output pairs, [math]\displaystyle{ \langle \mathbf{a}_0,\mathbf{y}_0 \rangle, \langle\mathbf{a}_1,\mathbf{y}_1 \rangle,\langle\mathbf{a}_2,\mathbf{y}_2\rangle,...,\langle\mathbf{a}_{k-1},\mathbf{y}_{k-1}\rangle }[/math]. An initial value must be specified for the hidden state [math]\displaystyle{ \mathbf{x}_0 }[/math]. Typically, a vector of all zeros is used for this purpose.

BPTT begins by unfolding a recurrent neural network in time. The unfolded network contains [math]\displaystyle{ k }[/math] inputs and outputs, but every copy of the network shares the same parameters. Then the backpropagation algorithm is used to find the gradient of the cost with respect to all the network parameters.

Consider an example of a neural network that contains a recurrent layer [math]\displaystyle{ f }[/math] and a feedforward layer [math]\displaystyle{ g }[/math]. There are different ways to define the training cost, but the aggregated cost is always the average of the costs of each of the time steps. The cost of each time step can be computed separately. The figure above shows how the cost at time [math]\displaystyle{ t + 3 }[/math] can be computed, by unfolding the recurrent layer [math]\displaystyle{ f }[/math] for three time steps and adding the feedforward layer [math]\displaystyle{ g }[/math]. Each instance of [math]\displaystyle{ f }[/math] in the unfolded network shares the same parameters. Thus the weight updates in each instance ([math]\displaystyle{ f_1, f_2, f_3 }[/math]) are summed together.

Pseudocode

Pseudocode for a truncated version of BPTT, where the training data contains [math]\displaystyle{ n }[/math] input-output pairs, but the network is unfolded for [math]\displaystyle{ k }[/math] time steps:

Back_Propagation_Through_Time(a, y)   // a[t] is the input at time t. y[t] is the output
    Unfold the network to contain k instances of f
    do until stopping criterion is met:
        x := the zero-magnitude vector // x is the current context
        for t from 0 to n − k do      // t is time. n is the length of the training sequence
            Set the network inputs to x, a[t], a[t+1], ..., a[t+k−1]
            p := forward-propagate the inputs over the whole unfolded network
            e := y[t+k] − p;           // error = target − prediction
            Back-propagate the error, e, back across the whole unfolded network
            Sum the weight changes in the k instances of f together.
            Update all the weights in f and g.
            x := f(x, a[t]);           // compute the context for the next time-step

Advantages

BPTT tends to be significantly faster for training recurrent neural networks than general-purpose optimization techniques such as evolutionary optimization.[4]

Disadvantages

BPTT has difficulty with local optima. With recurrent neural networks, local optima are a much more significant problem than with feed-forward neural networks.[5] The recurrent feedback in such networks tends to create chaotic responses in the error surface which cause local optima to occur frequently, and in poor locations on the error surface.

See also

References

  1. Mozer, M. C. (1995). "A Focused Backpropagation Algorithm for Temporal Pattern Recognition". in Chauvin, Y.; Rumelhart, D. (in en). Backpropagation: Theory, architectures, and applications. Hillsdale, NJ: Lawrence Erlbaum Associates. pp. 137–169. https://www.researchgate.net/publication/243781476. Retrieved 2017-08-21. 
  2. Template:Cite tech report
  3. Werbos, Paul J. (1988). "Generalization of backpropagation with application to a recurrent gas market model". Neural Networks 1 (4): 339–356. doi:10.1016/0893-6080(88)90007-x. https://zenodo.org/record/1258627. 
  4. Sjöberg, Jonas; Zhang, Qinghua; Ljung, Lennart; Benveniste, Albert; Delyon, Bernard; Glorennec, Pierre-Yves; Hjalmarsson, Håkan; Juditsky, Anatoli (1995). "Nonlinear black-box modeling in system identification: a unified overview". Automatica 31 (12): 1691–1724. doi:10.1016/0005-1098(95)00120-8. 
  5. M.P. Cuéllar and M. Delgado and M.C. Pegalajar (2006). "An Application of Non-Linear Programming to Train Recurrent Neural Networks in Time Series Prediction Problems". Enterprise Information Systems VII. Springer Netherlands. pp. 95–102. doi:10.1007/978-1-4020-5347-4_11. ISBN 978-1-4020-5323-8.