Advanced Topic 35 of 51 AI & Machine Learning
LSTM
Recurrent cells with gates preserving long-term information.
How it works
Long short-term memory networks are recurrent networks that add a cell state and gates to control information flow. The forget gate decides what to erase from the cell state, the input gate decides what new information to write and the output gate decides what to expose as the hidden state. Because the cell state is updated additively, gradients flow across many time steps, easing the vanishing gradient problem and letting the network learn long-range dependencies. GRU is a simplified variant with fewer gates.
Step-by-step walkthrough
- An LSTM adds a cell state that carries information along.
- The forget gate decides what to erase.
- The input gate decides what to write.
- The output gate decides what to expose.
- Gates let it remember across long sequences.
Where it is used
Speech and handwriting recognition, machine translation, text generation, time-series forecasting, anomaly detection and music modeling used LSTMs extensively before transformers.
Common pitfall
They are still sequential, slow to train and can struggle with very long contexts. They have many parameters per unit and are sensitive to hyperparameters and initialization. Forget gate bias is often initialized to a positive value. Use gradient clipping, dropout between layers and consider transformers or simpler models for modern tasks.
Where it fits in the course
LSTM is topic 35 of 51 in AI & Machine Learning, rated Advanced. It follows Recurrent Neural Networks. The next topic is Attention Mechanism.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the AI & Machine Learning quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the AI & Machine Learning quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is LSTM?
Where do people use LSTM?
What is the most common mistake with LSTM?
What should I learn before this topic?
How can I practice it?
Is LSTM hard to learn?
How long does it take to learn LSTM?
Which topics are related to LSTM?
What should I study after LSTM?
Related topics
- Recurrent Neural Networks (AI & Machine Learning)
- Attention Mechanism (AI & Machine Learning)
- Convolutional Neural Networks (AI & Machine Learning)
- Transformers (AI & Machine Learning)