Learn Before
Code
Prediction Implementation in RNNLMScratch
The predict method in the RNNLMScratch class generates a continuation of characters from a user-provided prefix. It initializes the hidden state and processes the prefix during a warm-up period to build context. After the warm-up, it iteratively predicts a specified number of subsequent characters. At each step of the generation phase, the newly predicted character is fed back into the RNN as the input for the next time step, and the output layer maps the hidden state to a vocabulary index.
0
1
Updated 2026-05-14
Tags
D2L
Dive into Deep Learning @ D2L