A recurrent neural network (RNN) processes sequential data one token at a time, combining the current input with a hidden state that remembers earlier tokens. For molecular design, this makes RNNs suitable for encoding and generating SMILES strings, where atom and bond order determines chemical structure. section 10.4 section 10.4.1
Figure 10.4 Unrolling an RNN for sequence processing. The left side shows the conceptual "rolled" representation of an RNN processing an input molecule. The right side shows the "unrolled" version that illustrates how the RNN processes the sequence. At each time step, the same neural network (purple circles) takes the current input token and the hidden state from the previous step (h_{t-1}) to produce an output (y_t) and an updated hidden state (h_t) that carries forward to the next step. This sequential processing allows the network to build up understanding of the molecular structure by maintaining memory of previously processed tokens through the evolving hidden state. The bias term is omitted for clarity.

Shows the same RNN cell repeated across time steps: each cell receives the current token and previous hidden state, then emits an output and updated memory. section 10.4.1
At each time step, the cell performs a small recurrent workflow:
- Start with an initial hidden state and the first token, such as a start-of-sequence marker. section 10.4.1
- Combine the current input vector with the previous hidden state to compute a new hidden state. section 10.4.1
- Use the new hidden state to produce the current output, then pass it forward with the memory. section 10.4.1
- Repeat the shared computation until the sequence ends; the final hidden state summarizes the complete input. section 10.4.1
Reading acetic acid as a sequence
For "CC(=O)O", the network receives carbon tokens first, then tracks that a branch begins, a double bond follows, the branch closes, and another oxygen attaches. The hidden state accumulates these relationships instead of treating the characters as an unordered bag. section 10.4.1
A simple RNN updates memory with a nonlinear transformation such as tanh, using learned input and hidden-state weights, then maps the new state to an output. Long sequences can cause vanishing gradients during backpropagation through time, making distant ring closures, functional-group relationships, and global valence consistency difficult to learn. section 10.4.1 section 10.4.2
Gated recurrent units (GRUs) address this limitation with a reset gate that controls retained history and an update gate that blends the previous state with a candidate state. This selective memory helps capture long-range SMILES dependencies more effectively than a basic RNN. section 10.4.2 section 10.5

















