Example
Seq2SeqAttentionDecoder Output Shape Verification
The Seq2SeqAttentionDecoder can be verified by instantiating a test configuration with vocab_size = 10, embed_size = 8, num_hiddens = 16, and num_layers = 2, then feeding a minibatch of 4 sequences, each with 7 time steps. After running the encoder and initializing the decoder state, the forward pass produces an output tensor of shape (batch_size, num_steps, vocab_size) = (4, 7, 10). The returned state contains the encoder outputs of shape (batch_size, num_steps, num_hiddens) = (4, 7, 16) and a per-layer decoder hidden state where each layer has shape (batch_size, num_hiddens) = (4, 16).
0
1
Updated 2026-06-20
Tags
D2L
Dive into Deep Learning @ D2L