RNN, LSTM and sequence learning
Understand recurrent state, gated memory and sequence training.
Compare recurrent architectures and transformers for variable-length sequence problems.
Interview questions
Choose a question to reveal its answer.
01EasyCoreHow does an RNN process a sequence?
Answer
How does an RNN process a sequence?
Processes sequence steps using a recurrent hidden state.
Summarize a stream of measurements one time step at a time.
import torch
from torch import nn
x = torch.randn(2, 5, 8)
model = nn.LSTM(8, 16, batch_first=True)
y, (h, c) = model(x)
print(y.shape)Batch size two, five time steps, 16 output features.
02EasyCoreWhat does a recurrent hidden state store?
Answer
What does a recurrent hidden state store?
Internal representation passed between recurrent time steps.
Carry information from earlier words into processing the next word.
03EasyCoreHow does backpropagation through time work?
Answer
How does backpropagation through time work?
Computes gradients by differentiating through unrolled recurrent steps.
Train shared recurrent weights across a sequence.
04MediumHigh priorityVisualWhy do gradients vanish in recurrent networks?
Answer
Why do gradients vanish in recurrent networks?
Gradient magnitude becomes very small through repeated transformations.
Earlier time steps receive little learning signal.
05MediumHigh priorityHow do exploding gradients affect training?
Answer
How do exploding gradients affect training?
Gradient magnitude grows excessively through repeated transformations.
Observe unstable large parameter updates during recurrent training.
06MediumHow does LSTM retain information across time steps?
Answer
How does LSTM retain information across time steps?
Gated recurrent architecture with a cell state designed to manage long-range information.
Retain relevant events over many sequence positions.
07MediumWhat does the LSTM forget gate do?
Answer
What does the LSTM forget gate do?
LSTM mechanism controlling how much previous cell state is retained.
Discard outdated contextual information.
08MediumWhat does the LSTM input gate do?
Answer
What does the LSTM input gate do?
LSTM mechanism controlling how much candidate information is written to the cell.
Update memory with a relevant new observation.
09HardHow does a GRU differ from an LSTM?
Answer
How does a GRU differ from an LSTM?
Gated recurrent unit using update and reset gates without a separate LSTM-style cell state.
Use a simpler gated recurrence for sequence classification.
10HardWhen is bidirectional recurrence appropriate?
Answer
When is bidirectional recurrence appropriate?
Combines forward and backward sequence processing when both contexts are available.
Tag words using preceding and following text in an offline task.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.