I was wondering if there is a more efficient way of padding sequences. The easiest option is to just pad all sequences to the max length possible, currently I implemented my own Dataset object and use a Transform that pads all sequences to the same length. But is there a way to do that per batch and not globally for the whole dataset (pad the batch when DataLoader samples the batch)? Sounds like I need to create a DataLoader?
Edit:
I found a possible solution at: http://pytorch.org/docs/master/_modules/torch/utils/data/sampler.html 1.0k.
Specifically, you can implement your own version of BatchSampler to padd the according to the longest sequence in the batch. I will post my implementatino when done.