Comparison

Unidirectional vs. Bidirectional Encoder in Seq2Seq

In the encoder component of a sequence-to-sequence model, the choice between a unidirectional and a bidirectional RNN determines how much input context each hidden state can capture. A unidirectional RNN encoder computes hidden states that depend solely on the input subsequence at and before the current time step, meaning each ht\mathbf{h}_t encodes only the tokens x1,,xtx_1, \ldots, x_t. In contrast, a bidirectional RNN encoder produces hidden states that also incorporate information from tokens appearing after the current position, effectively encoding the information of the entire input sequence at every time step. While a bidirectional encoder provides richer context, the unidirectional design is simpler and sufficient for many seq2seq applications.

0

1

Updated 2026-05-14

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L