Visualize how Long Short-Term Memory networks pass both a Cell State (long-term memory) and a Hidden State (short-term memory) forward to process sequences.
Discover how Long Short-Term Memory networks use a dual-state architecture to overcome the limitations of standard RNNs.
Standard Recurrent Neural Networks (RNNs) pass a single "hidden state" forward through time. While great in theory, standard RNNs suffer from the vanishing gradient problem. During training, as the network looks back across many time steps (long sentences), the signals necessary to update the weights become microscopically small.
The result? A standard RNN essentially develops "amnesia." By the time it reads the 20th word in a sentence, it has mostly forgotten the 1st word. This makes it terrible at understanding long-range dependencies in text.
LSTMs solve this amnesia by introducing a more complex internal structure that passes two distinct states forward at every time step (as seen in the visualization):
To control what gets added to or removed from the Cell State conveyor belt, the LSTM uses neural network layers called gates. Inside every single LSTM cell block shown in the visual, there are actually four separate fully-connected layers operating simultaneously:
Because there are 4 independent layers doing calculations on the inputs ($X_t$) and previous hidden state ($H_{t-1}$), an LSTM has roughly 4 times as many parameters as a standard RNN of the same size. Click the Parameters button to see the math.
Visualize how Long Short-Term Memory networks pass both a Cell State (long-term memory) and a Hidden State (short-term memory) forward to process sequences.