RNN Basics: Neural Networks with Memory
Traditional neural networks (like CNNs or MLPs) are feed-forward; they assume that all inputs are independent of each other. This is a problem for data that comes in a specific order, such as:
- Text: The meaning of a word depends on the words before it.
- Audio: A sound wave is a continuous sequence over time.
- Stock Prices: Today's price is highly dependent on yesterday's trend.
Recurrent Neural Networks (RNNs) solve this by introducing a "loop" that allows information to persist.
1. The Core Idea: The Hidden State
The defining feature of an RNN is the Hidden State (). You can think of this as the "memory" of the network. As the network processes each element in a sequence, it updates this hidden state based on the current input and the previous hidden state.
The Mathematical Step
At every time step , the RNN performs two operations:
- Update Hidden State:
- Calculate Output:
- : Input at time .