A recurrent network reads a series one step at a time and carries a state: a short list of numbers, its memory. Follow that state through 12 months of the airline data, check one slot's arithmetic by hand, and see why the same network is stuck on raw passenger counts and works once the data is prepared.
Explained in Part 1: dense network vs RNNPart 2: the RNN
Click a month to forecast it. The network reads the 12 months before it, one at a time, and the grid below shows what happens inside.
Simple exponential smoothing keeps one number, the level. The new level is a fraction α of the new observation, plus the rest of the old level. That is a weight times the input, plus a weight times the previous state: the recurrent cell with one slot, no tanh, and the two weights tied together.
| Exponential smoothing | Recurrent cell | |
|---|---|---|
| Memory | 1 number: the level | Many slots (16 here) |
| Weight on the input | α | W, free to learn |
| Weight on the old state | 1 − α | U, free to learn |
| Squashing | None | tanh, keeps every slot between −1 and 1 |
| Trained to | Smooth the series | Do whatever helps the forecast |
Slide α and you are changing both weights at once. An RNN learns its weights separately for every slot, which is why it needs far more data than smoothing does. To explore smoothing on its own, open the simple exponential smoothing tool.
Think of each number as a slot of memory. One slot might follow the recent level, one the trend, one the season. Nobody assigns those jobs. Training does.
New state = tanh(W × input + U × old state + bias). The same weights are used for month 1 and month 12. That is why an RNN can read a short window or a long one with the same number of weights.
tanh is flat beyond about 3. A raw count like 112, times an ordinary weight, lands far out on the flat part, so every slot answers 1 or −1 whatever the month. Rescale the data, always, with the mean and standard deviation of the training data only.
A state made of numbers between −1 and 1 does not reach far beyond what it saw in training, and the test year is higher than every training year. Taking logs and differences removes the trend, and the same network becomes a good forecaster. Next: how a dense network sees the same data.