# Different length sequences as batch input to LSTM

**URL:** <https://discuss.pytorch.org/t/different-length-sequences-as-batch-input-to-lstm/66119>\
**Category:** Uncategorized\
**Created:** [January 8, 2020, 6:27pm UTC](https://discuss.pytorch.org/t/different-length-sequences-as-batch-input-to-lstm/66119 "2020-01-08T18:27:13Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![vdw](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/vdw/32/10074_2.png) [@vdw](https://discuss.pytorch.org/u/vdw)\
**Post date:** [January 9, 2020, 9:18am UTC](https://discuss.pytorch.org/t/different-length-sequences-as-batch-input-to-lstm/66119/3 "2020-01-09T09:18:53Z")

</div>

You have two basic alternatives:

- [Use padding (& packing).](https://discuss.pytorch.org/t/understanding-pack-padded-sequence-and-pad-packed-sequence/4099/17) That’s a standard practice to handle batch sequences of different lengths.
- [Organize your batches in such way that all sequences withing one batch have the same length.](https://discuss.pytorch.org/t/using-batches-for-seq2seq-models/55205)

---

_[View the full topic](https://discuss.pytorch.org/t/different-length-sequences-as-batch-input-to-lstm/66119)._
