The training data for a recurrent neural network is an ordered sequence of k {\displaystyle k} input-output pairs, ⟨ a 0 , y 0 ⟩ , ⟨ a 1 , y 1 ⟩ , ⟨ a 2 , y 2 ⟩ , . . . , ⟨ a k − 1 , y k − 1 ⟩ {\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 } . An initial value must be specified for the hidden state x 0 {\displaystyle \mathbf {x} _{0}} , typically chosen to be a zero vector.
BPTT begins by unfolding a recurrent neural network in time. The unfolded network contains k {\displaystyle k} 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 loss function with respect to all the network parameters.
Consider an example of a neural network that contains a recurrent layer f {\displaystyle f} and a feedforward layer g {\displaystyle g} . 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 t + 3 {\displaystyle t+3} can be computed, by unfolding the recurrent layer f {\displaystyle f} for three time steps and adding the feedforward layer g {\displaystyle g} . Each instance of f {\displaystyle f} in the unfolded network shares the same parameters. Thus, the weight updates in each instance ( f 1 , f 2 , f 3 {\displaystyle f_{1},f_{2},f_{3}} ) are summed together.
Below is pseudocode for a truncated version of BPTT, where the training data contains n {\displaystyle n} input-output pairs, and the network is unfolded for k {\displaystyle k} time steps:
BPTT tends to be significantly faster for training recurrent neural networks than general-purpose optimization techniques such as evolutionary optimization.4
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.
Mozer, M. C. (1995). "A Focused Backpropagation Algorithm for Temporal Pattern Recognition". In Chauvin, Y.; Rumelhart, D. (eds.). Backpropagation: Theory, architectures, and applications. Hillsdale, NJ: Lawrence Erlbaum Associates. pp. 137–169. Retrieved 2017-08-21. {{cite book}}: |website= ignored (help) https://www.researchgate.net/publication/243781476 ↩
Robinson, A. J. & Fallside, F. (1987). The utility driven dynamic error propagation network (Technical report). Cambridge University, Engineering Department. CUED/F-INFENG/TR.1. https://www.bibsonomy.org/bibtex/269a88ecbac9a51cbf0b4be189c412820/idsia ↩
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 ↩
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. CiteSeerX 10.1.1.27.81. doi:10.1016/0005-1098(95)00120-8. /wiki/H%C3%A5kan_Hjalmarsson ↩
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. 978-1-4020-5323-8 ↩