concept RNN in category deep learning

This is an excerpt from Manning's book Deep Learning with JavaScript: Neural networks in TensorFlow.js.
In listing 9.1, you can see that the output at time step i becomes the “state” for the next time step (next iteration). State is an important concept for RNNs. It is how an RNN “remembers” what happened in the steps of the input sequence it has already seen. In the for loop, this memory state gets combined with future input steps and becomes the new memory state. This gives the simpleRNN the ability to react to the same input element differently depending on what elements have appeared in the sequence before. This type of memory-based sensitivity is at the heart of sequential processing. As a simple example, if you are trying to decode Morse code (made of dots and dashes), the meaning of a dash depends on the sequence of dots and dashes that go before (and after) it. As another example, in English, the word last can have completely different meanings depending on what words go before it.
Figure 10.1. A schematic illustration of how an RNN-based next-character predictor can be used to generate a sequence of text from an initial input snippet of text as the seed. At each step, the RNN predicts the next character using the input text. Then, the input text is concatenated with the predicted next character and discards the first character. The result forms the input for the next step. At each step, the RNN outputs the probability scores for all possible characters in the character set. To determine the actual next character, a random sampling is carried out.
![]()