Pack Sequences & Handle Padding
Train efficiently on variable lengths.
Batches Want Rectangles
To process many sequences at once, a batch must be a neat rectangle. But real sentences have different lengths, so they don't line up.
Padding to a Common Length
The fix is padding: add filler tokens, usually zeros, to short sequences so every row in the batch is the same length.
All lessons in this course
- Why Sequences Need Memory
- The Vanilla RNN Cell
- LSTM & GRU Gates
- Pack Sequences & Handle Padding