The recurrent cell family
RNNs process sequences one step at a time, maintaining a hidden state that summarizes everything seen so far. Each step takes the current input and the previous hidden state, produces a new hidden state, and (optionally) an output.
SimpleRNN is the most basic cell. It struggles past 20–30 time steps because gradients vanish or explode through deep unrolled computation.
LSTM (Long Short-Term Memory) solves the vanishing gradient problem with a two-stream architecture: a cell state (long-term memory) and a hidden state (working memory). Three gates — forget, input, output — control information flow. LSTMs reliably model dependencies of hundreds of time steps.
GRU (Gated Recurrent Unit) is a streamlined LSTM with two gates instead of three, merging cell and hidden state. ~25% fewer parameters than equivalent LSTM, similar accuracy on most tasks, faster training. Set reset_after=True for the CuDNN-optimized GPU implementation — up to 5× faster than the default.