From Surf Wiki (app.surf) — the open knowledge base
Long short-term memory
Recurrent neural network architecture
Recurrent neural network architecture
Long short-term memory (LSTM) is a type of recurrent neural network (RNN) aimed at mitigating the vanishing gradient problem commonly encountered by traditional RNNs. Its relative insensitivity to gap length is its advantage over other RNNs, hidden Markov models, and other sequence learning methods. It aims to provide a short-term memory for RNN that can last thousands of timesteps (thus "long short-term memory"). The name is made in analogy with long-term memory and short-term memory and their relationship, studied by cognitive psychologists since the early 20th century.
An LSTM unit is typically composed of a cell and three gates: an input gate, an output gate, and a forget gate. The cell remembers values over arbitrary time intervals, and the gates regulate the flow of information into and out of the cell. Forget gates decide what information to discard from the previous state, by mapping the previous state and the current input to a value between 0 and 1. A (rounded) value of 1 signifies retention of the information, and a value of 0 represents discarding. Input gates decide which pieces of new information to store in the current cell state, using the same system as forget gates. Output gates control which pieces of information in the current cell state to output, by assigning a value from 0 to 1 to the information, considering the previous and current states. Selectively outputting relevant information from the current state allows the LSTM network to maintain useful, long-term dependencies to make predictions, both in current and future time-steps.
LSTM has wide applications in classification, data processing, time series analysis tasks, speech recognition, machine translation, speech activity detection, robot control, video games, healthcare, energy forecasting.
Motivation
In theory, classic RNNs can keep track of arbitrary long-term dependencies in the input sequences. The problem with classic RNNs is computational (or practical) in nature: when training a classic RNN using back-propagation, the long-term gradients which are back-propagated can "vanish", meaning they can tend to zero due to very small numbers creeping into the computations, causing the model to effectively stop learning. RNNs using LSTM units partially solve the vanishing gradient problem, because LSTM units allow gradients to also flow with little to no attenuation. However, LSTM networks can still suffer from the exploding gradient problem.
The intuition behind the LSTM architecture is to create an additional module in a neural network that learns when to remember and when to forget pertinent information. In other words, the network effectively learns which information might be needed later on in a sequence and when that information is no longer needed. For instance, in the context of natural language processing, the network can learn grammatical dependencies. An LSTM might process the sentence "Dave, as a result of his controversial claims, is now a pariah" by remembering the (statistically likely) grammatical gender and number of the subject Dave. Note that this information is pertinent for the pronoun his and note that this information is no longer important after the verb is.
Variants
In the equations below, the lowercase variables represent vectors. Matrices W_q and U_q contain, respectively, the weights of the input and recurrent connections, where the subscript _q can either be the input gate i, output gate o, the forget gate f or the memory cell c, depending on the activation being calculated. In this section, we are thus using a "vector notation". So, for example, c_t \in \mathbb{R}^{h} is not just one unit of one LSTM cell, but contains h LSTM cell's units.
LSTM with a forget gate
The compact forms of the equations for the forward pass of an LSTM cell with a forget gate are:{{Cite journal
: \begin{align} f_t &= \sigma_g(W_{f} x_t + U_{f} h_{t-1} + b_f) \ i_t &= \sigma_g(W_{i} x_t + U_{i} h_{t-1} + b_i) \ o_t &= \sigma_g(W_{o} x_t + U_{o} h_{t-1} + b_o) \ \tilde{c}t &= \sigma_c(W{c} x_t + U_{c} h_{t-1} + b_c) \ c_t &= f_t \odot c_{t-1} + i_t \odot \tilde{c}_t \ h_t &= o_t \odot \sigma_h(c_t) \end{align}
where the initial values are c_0 = 0 and h_0 = 0 and the operator \odot denotes the Hadamard product (element-wise product). The subscript t indexes the time step.
Variables
Letting the superscripts d and h refer to the number of input features and number of hidden units, respectively:
- x_t \in \mathbb{R}^{d}: input vector to the LSTM unit
- f_t \in {(0,1)}^{h}: forget gate's activation vector
- i_t \in {(0,1)}^{h}: input/update gate's activation vector
- o_t \in {(0,1)}^{h}: output gate's activation vector
- h_t \in {(-1,1)}^{h}: hidden state vector also known as output vector of the LSTM unit
- \tilde{c}_t \in {(-1,1)}^{h}: cell input activation vector
- c_t \in \mathbb{R}^{h}: cell state vector
- W \in \mathbb{R}^{h \times d}, U \in \mathbb{R}^{h \times h} and b \in \mathbb{R}^{h}: weight matrices and bias vector parameters which need to be learned during training
[[Activation function]]s
- \sigma_g: sigmoid function.
- \sigma_c: hyperbolic tangent function.
- \sigma_h: hyperbolic tangent function or, as the peephole LSTM paper suggests, \sigma_h(x) = x.
Peephole LSTM
The figure on the right is a graphical representation of an LSTM unit with peephole connections (i.e. a peephole LSTM). Peephole connections allow the gates to access the constant error carousel (CEC), whose activation is the cell state. h_{t-1} is not used, c_{t-1} is used instead in most places. : \begin{align} f_t &= \sigma_g(W_{f} x_t + U_{f} c_{t-1} + b_f) \ i_t &= \sigma_g(W_{i} x_t + U_{i} c_{t-1} + b_i) \ o_t &= \sigma_g(W_{o} x_t + U_{o} c_{t-1} + b_o) \ c_t &= f_t \odot c_{t-1} + i_t \odot \sigma_c(W_{c} x_t + b_c) \ h_t &= o_t \odot \sigma_h(c_t) \end{align}
Each of the gates can be thought as a "standard" neuron in a feed-forward (or multi-layer) neural network: that is, they compute an activation (using an activation function) of a weighted sum. i_t, o_t and f_t represent the activations of respectively the input, output and forget gates, at time step t.
The 3 exit arrows from the memory cell c to the 3 gates i, o and f represent the peephole connections. These peephole connections actually denote the contributions of the activation of the memory cell c at time step t-1, i.e. the contribution of c_{t-1} (and not c_{t}, as the picture may suggest). In other words, the gates i, o and f calculate their activations at time step t (i.e., respectively, i_t, o_t and f_t) also considering the activation of the memory cell c at time step t - 1, i.e. c_{t-1}.
The single left-to-right arrow exiting the memory cell is not a peephole connection and denotes c_{t}.
The little circles containing a \times symbol represent an element-wise multiplication between its inputs. The big circles containing an S-like curve represent the application of a differentiable function (like the sigmoid function) to a weighted sum.
Peephole convolutional LSTM
Peephole convolutional LSTM.{{Cite journal : \begin{align} f_t &= \sigma_g(W_{f} * x_t + U_{f} * h_{t-1} + V_{f} \odot c_{t-1} + b_f) \ i_t &= \sigma_g(W_{i} * x_t + U_{i} * h_{t-1} + V_{i} \odot c_{t-1} + b_i) \ c_t &= f_t \odot c_{t-1} + i_t \odot \sigma_c(W_{c} * x_t + U_{c} * h_{t-1} + b_c) \ o_t &= \sigma_g(W_{o} * x_t + U_{o} * h_{t-1} + V_{o} \odot c_{t} + b_o) \ h_t &= o_t \odot \sigma_h(c_t) \end{align}
Training
An RNN using LSTM units can be trained in a supervised fashion on a set of training sequences, using an optimization algorithm like gradient descent combined with backpropagation through time to compute the gradients needed during the optimization process, in order to change each weight of the LSTM network in proportion to the derivative of the error (at the output layer of the LSTM network) with respect to corresponding weight.
A problem with using gradient descent for standard RNNs is that error gradients vanish exponentially quickly with the size of the time lag between important events. This is due to \lim_{n \to \infty}W^n = 0 if the spectral radius of W is smaller than 1.
However, with LSTM units, when error values are back-propagated from the output layer, the error remains in the LSTM unit's cell. This "error carousel" continuously feeds error back to each of the LSTM unit's gates, until they learn to cut off the value.
CTC score function
Many applications use stacks of LSTM RNNs and train them by connectionist temporal classification (CTC) to find an RNN weight matrix that maximizes the probability of the label sequences in a training set, given the corresponding input sequences. CTC achieves both alignment and recognition.
Alternatives
Sometimes, it can be advantageous to train (parts of) an LSTM by neuroevolution or by policy gradient methods, especially when there is no "teacher" (that is, training labels).
Applications
Applications of LSTM include:
- Robot control
- Time series prediction
- Speech recognition
- Rhythm learning
- Hydrological rainfall–runoff modeling
- Music composition
- Grammar learning
- Handwriting recognition
- Human action recognition
- Sign language translation
- Protein homology detection{{Cite journal | doi-access = free
- Predicting subcellular localization of proteins
- Time series anomaly detection
- Several prediction tasks in the area of business process management
- Prediction in medical care pathways
- Semantic parsing
- Object co-segmentation{{cite conference | last1=Duan | first1=Xuhuan | last2=Wang | first2=Le | last3=Zhai | first3=Changbo | last4=Zheng | first4=Nanning | last5=Zhang | first5=Qilin | last6=Niu | first6=Zhenxing | last7=Hua | first7=Gang | title=2018 25th IEEE International Conference on Image Processing (ICIP) | chapter=Joint Spatio-Temporal Action Localization in Untrimmed Videos with Per-Frame Segmentation | publisher=25th IEEE International Conference on Image Processing (ICIP)
- Airport passenger management
- Short-term traffic forecast
- Drug design
- Financial forecasting
- Activity classification in video 2015: Google started using an LSTM trained by CTC for speech recognition on Google Voice. According to the official blog post, the new model cut transcription errors by 49%.
2016: Google started using an LSTM to suggest messages in the Allo conversation app. In the same year, Google released the Google Neural Machine Translation system for Google Translate which used LSTMs to reduce translation errors by 60%.
Apple announced in its Worldwide Developers Conference that it would start using the LSTM for quicktype in the iPhone and for Siri.
Amazon released Polly, which generates the voices behind Alexa, using a bidirectional LSTM for the text-to-speech technology.
2017: Facebook performed some 4.5 billion automatic translations every day using long short-term memory networks.
Microsoft reported reaching 94.9% recognition accuracy on the Switchboard corpus, incorporating a vocabulary of 165,000 words. The approach used "dialog session-based long-short-term memory".
2018: OpenAI used LSTM trained by policy gradients to beat humans in the complex video game of Dota 2, and to control a human-like robot hand that manipulates physical objects with unprecedented dexterity.
2019: DeepMind used LSTM trained by policy gradients to excel at the complex video game of Starcraft II.
History
Development
Aspects of LSTM were anticipated by "focused back-propagation", cited by the LSTM paper.
Sepp Hochreiter's 1991 German diploma thesis analyzed the vanishing gradient problem and developed principles of the method.{{cite thesis
An early version of LSTM was published in 1995 in a technical report by Sepp Hochreiter and Jürgen Schmidhuber, then published in the NIPS 1996 conference.
The most commonly used reference point for LSTM was published in 1997 in the journal Neural Computation.{{Cite journal | author2-link = Jürgen Schmidhuber | author-link = Sepp Hochreiter
Felix Gers, Jürgen Schmidhuber, and Fred Cummins introduced the forget gate (also called "keep gate") into the LSTM architecture in 1999, enabling the LSTM to reset its own state. This is the most commonly used version of LSTM nowadays. They added peephole connections in 2000. Additionally, the output activation function was omitted.
Development of variants
In 2005 Graves and Schmidhuber published LSTM with full backpropagation through time and bidirectional LSTM.
In 2006 Graves, Fernandez, Gomez, and Schmidhuber introduced a new error function for LSTM: Connectionist Temporal Classification (CTC) for simultaneous alignment and recognition of sequences.
In 2014 Kyunghyun Cho an others published a simplified variant of the forget gate LSTM called Gated recurrent unit (GRU).
In 2015 Srivastava, Greff, and Schmidhuber used LSTM principles to create the Highway network, a feedforward neural network with hundreds of layers, much deeper than previous networks. Concurrently, the ResNet architecture was developed. It is equivalent to an open-gated or gateless highway network.
A modern upgrade of LSTM called xLSTM is published by a team led by Sepp Hochreiter. One of the 2 blocks (mLSTM) of the architecture are parallelizable like the Transformer architecture, the other ones (sLSTM) allow state tracking.
Applications
2001: Gers and Schmidhuber trained LSTM to learn languages unlearnable by traditional models such as Hidden Markov Models.
Hochreiter et al. used LSTM for meta-learning (i.e. learning a learning algorithm).
2004: First successful application of LSTM to speech Alex Graves et al.
2005: Daan Wierstra, Faustino Gomez, and Schmidhuber trained LSTM by neuroevolution without a teacher.
Mayer et al. trained LSTM to control robots.
2007: Wierstra, Foerster, Peters, and Schmidhuber trained LSTM by policy gradients for reinforcement learning without a teacher.
Hochreiter, Heuesel, and Obermayr applied LSTM to protein homology detection the field of biology.
2009: Justin Bayer et al. introduced neural architecture search for LSTM.
2009: An LSTM trained by CTC won the ICDAR connected handwriting recognition competition. Three such models were submitted by a team led by Alex Graves. One was the most accurate model in the competition and another was the fastest. This was the first time an RNN won international competitions.
2013: Alex Graves, Abdel-rahman Mohamed, and Geoffrey Hinton used LSTM networks as a major component of a network that achieved a record 17.7% phoneme error rate on the classic TIMIT natural speech dataset.
2017: Researchers from Michigan State University, IBM Research, and Cornell University published a study in the Knowledge Discovery and Data Mining (KDD) conference. Their time-aware LSTM (T-LSTM) performs better on certain data sets than standard LSTM.
References
References
- (1996-12-03). "LSTM can solve hard long time lag problems". MIT Press.
- (2018). "LSTM Fully Convolutional Networks for Time Series Classification". IEEE Access.
- (2014). "Long Short-Term Memory recurrent neural network architectures for large scale acoustic modeling".
- (2014-10-15). "Constructing Long Short-Term Memory based Deep Recurrent Neural Networks for Large Vocabulary Speech Recognition".
- (2016-09-26). "Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation".
- Ong, Thuy. (4 August 2017). "Facebook's translations are now powered completely by AI".
- (2019-11-06). "The Speed Submission to DIHARD II: Contributions & Lessons Learned".
- (July 30, 2018). "Learning Dexterity". OpenAI.
- Rodriguez, Jesus. (July 2, 2018). "The Science Behind OpenAI Five that just Produced One of the Greatest Breakthrough in the History of AI". Towards Data Science.
- Stanford, Stacy. (January 25, 2019). "DeepMind's AI, AlphaStar Showcases Significant Progress Towards AGI". Medium ML Memoirs.
- Schmidhuber, Jürgen. (2021). "The 2010s: Our Decade of Deep Learning / Outlook on the 2020s". AI Blog.
- (23 January 2026). "Forecasting Energy Consumption using Recurrent Neural Networks: A Comparative Analysis". arXiv.
- (14 February 2020). "Deep Learning Architectures". Springer Nature.
- (2019). "The emergence of number and syntax units". Association for Computational Linguistics.
- (2001). "A Field Guide to Dynamical Recurrent Neural Networks.". IEEE Press.
- (2007). "Sequence labelling in structured domains with hierarchical recurrent neural networks". Proc. 20th Int. Joint Conf. On Artificial Intelligence, Ijcai 2007.
- (2006). "Connectionist temporal classification: Labelling unsegmented sequence data with recurrent neural networks". In Proceedings of the International Conference on Machine Learning, ICML 2006.
- (October 2006). "2006 IEEE/RSJ International Conference on Intelligent Robots and Systems".
- (2005). "Evolino: Hybrid Neuroevolution/Optimal Linear Search for Sequence Learning". Proceedings of the 19th International Joint Conference on Artificial Intelligence (IJCAI), Edinburgh.
- (2005). "Framewise phoneme classification with bidirectional LSTM and other neural network architectures". Neural Networks.
- (9 September 2007). "An Application of Recurrent Neural Networks to Discriminative Keyword Spotting". Springer-Verlag.
- (2013). "2013 IEEE International Conference on Acoustics, Speech and Signal Processing".
- (2002). "Learning precise timing with LSTM recurrent networks". Journal of Machine Learning Research.
- (2019-12-17). "Towards learning universal, regional, and local hydrological behaviors via machine learning applied to large-sample datasets". Hydrology and Earth System Sciences.
- (2002-08-28). "Artificial Neural Networks — ICANN 2002". Springer, Berlin, Heidelberg.
- (2002). "Learning nonregular languages: A comparison of simple recurrent networks and LSTM". Neural Computation.
- (2001). "LSTM Recurrent Networks Learn Simple Context Free and Context Sensitive Languages". IEEE Transactions on Neural Networks.
- (2003). "Kalman filters improve LSTM network performance in problems unsolvable by traditional recurrent nets". Neural Networks.
- A. Graves, J. Schmidhuber. Offline Handwriting Recognition with Multidimensional Recurrent Neural Networks. Advances in Neural Information Processing Systems 22, NIPS'22, pp 545–552, Vancouver, MIT Press, 2009.
- (3 December 2007). "Unconstrained Online Handwriting Recognition with Recurrent Neural Networks". Curran Associates Inc..
- (2011). "2nd International Workshop on Human Behavior Understanding (HBU)". Springer.
- (2018-01-30). "Video-based Sign Language Recognition without Temporal Segmentation".
- (2007). "Bidirectional Long Short-Term Memory Networks for predicting the subcellular localization of eukaryotic proteins". IEEE/ACM Transactions on Computational Biology and Bioinformatics.
- (April 2015). "Long Short Term Memory Networks for Anomaly Detection in Time Series". European Symposium on Artificial Neural Networks, Computational Intelligence and Machine Learning — ESANN 2015.
- (2017). "Advanced Information Systems Engineering".
- (2016). "Doctor AI: Predicting Clinical Events via Recurrent Neural Networks". JMLR Workshop and Conference Proceedings.
- (2016). "Data Recombination for Neural Semantic Parsing".
- (2018-05-22). "Segment-Tube: Spatio-Temporal Action Localization in Untrimmed Videos with Per-Frame Segmentation". Sensors.
- (2019). "Neural networks trained with WiFi traces to predict airport passenger behavior". IEEE.
- (2017). "LSTM network: A deep learning approach for Short-term traffic forecast". IET Intelligent Transport Systems.
- Gupta A, Müller AT, Huisman BJH, Fuchs JA, Schneider P, Schneider G. (2018). "Generative Recurrent Networks for De Novo Drug Design.". Mol Inform.
- (2020-10-26). "Foreign Exchange Currency Rate Prediction using a GRU-LSTM Hybrid Network". Soft Computing Letters.
- (2024-05-27). "Automatic excavator action recognition and localisation for untrimmed video using hybrid LSTM-Transformer networks". International Journal of Mining, Reclamation and Environment.
- Beaufays, Françoise. (August 11, 2015). "The neural networks behind Google Voice transcription". Research Blog.
- (September 24, 2015). "Google voice search: faster and more accurate". Research Blog.
- (23 July 2015). "Neon prescription... or rather, New transcription for Google Voice".
- Khaitan, Pranav. (May 18, 2016). "Chat Smarter with Allo". Research Blog.
- Metz, Cade. (September 27, 2016). "An Infusion of AI Makes Google Translate More Powerful Than Ever {{!}} WIRED".
- (27 September 2016). "A Neural Network for Machine Translation, at Production Scale".
- Efrati, Amir. (June 13, 2016). "Apple's Machines Can Learn Too".
- Ranger, Steve. (June 14, 2016). "iPhone, AI and big data: Here's how Apple plans to protect your privacy". ZDNet.
- "Can Global Semantic Context Improve Neural Language Models? – Apple".
- Smith, Chris. (2016-06-13). "iOS 10: Siri now works in third-party apps, comes with extra AI features".
- (2017-08-20). "Siri On-Device Deep Learning-Guided Unit Selection Text-to-Speech System". ISCA.
- Vogels, Werner. (30 November 2016). "Bringing the Magic of Amazon AI and Alexa to Apps on AWS. – All Things Distributed".
- (April 2018). "2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)". IEEE.
- (1989). "A Focused Backpropagation Algorithm for Temporal Pattern Recognition". Complex Systems.
- Schmidhuber, Juergen. (2022). "Annotated History of Modern AI and Deep Learning".
- {{Cite Q. Q98967430
- (2015). "LSTM: A Search Space Odyssey". IEEE Transactions on Neural Networks and Learning Systems.
- (1999). "9th International Conference on Artificial Neural Networks: ICANN '99".
- (2014). "Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation".
- (2 May 2015). "Highway Networks".
- (December 2015). "Training Very Deep Networks". MIT Press.
- Schmidhuber, Jürgen. (2021). "The most cited neural networks all build on work done in my labs". AI Blog.
- (2016). "2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)". IEEE.
- (2024-05-07). "xLSTM: Extended Long Short-Term Memory".
- (2024-06-04). "NX-AI/xlstm". NXAI.
- (2001). "Artificial Neural Networks — ICANN 2001".
- (2004). "Biologically Plausible Speech Recognition with LSTM Neural Nets.".
- Schmidhuber, Juergen. (10 May 2021). "Deep Learning: Our Miraculous Year 1990-1991".
- (2005). "Solving Deep Memory POMDPs with Recurrent Policy Gradients". International Conference on Artificial Neural Networks ICANN'07.
- (2009). "Evolving memory cell structures for sequence learning". International Conference on Artificial Neural Networks ICANN'09, Cyprus.
- (May 2009). "A Novel Connectionist System for Unconstrained Handwriting Recognition". IEEE Transactions on Pattern Analysis and Machine Intelligence.
- (July 2009). "2009 10th International Conference on Document Analysis and Recognition".
- (2017-08-04). "Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining". Association for Computing Machinery.
This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.
Ask Mako anything about Long short-term memory — get instant answers, deeper analysis, and related topics.
Research with MakoFree with your Surf account
Create a free account to save articles, ask Mako questions, and organize your research.
Sign up freeThis content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.
Report