A bidirectional recurrent neural network encodes a complete sequence with two recurrent networks: one reads left to right, the other right to left. Their hidden states give each position information from both preceding and succeeding tokens. For molecular generation, this encoder processes a SMILES string before a decoder reconstructs or generates another string. section 10.4.3
A practical molecular encoder typically follows these steps:
- Process the embedded sequence with forward and backward recurrent layers. section 10.4.3
Bidirectional GRU molecular encoder
A PyTorch encoder embeds padded SMILES batches, optionally packs sequences using their lengths, runs a bidirectional GRU, reshapes its directional hidden states, and concatenates the final forward and backward states.




