Add drop_last arg for data loader#4757
Conversation
|
Hi! This looks like a cool feature to add, indeed. I'm curious, what was the error you obtained because of an incomplete batch? It shouldn't raise an error if a batch is smaller than what it has previously seen. I could see it being useful when the framework needs to trace with a given input size though, like with TPUs or with JAX. |
|
Hey @LysandreJik, thanks for taking a look! This error occurred on the last step of the epoch: Because of the nature of the error and it occurring on the last step, my suspicion was it was because of |
Codecov Report
@@ Coverage Diff @@
## master #4757 +/- ##
==========================================
- Coverage 77.41% 77.34% -0.08%
==========================================
Files 128 128
Lines 21059 21060 +1
==========================================
- Hits 16302 16288 -14
- Misses 4757 4772 +15
Continue to review full report at Codecov.
|
|
I'm assuming you use GPU distribution – what method do you use for distribution? |
|
@julien-c: Correct, it is using |
There was a problem hiding this comment.
nit:
| data_loader_drop_last: bool = field( | |
| dataloader_drop_last: bool = field( |
|
It should work out of the box with torch.distributed instead of nn.DataParallel. I have no objection to merging this though :) |
|
Hmmm, this was on AWS SageMaker, so I'll double-check how it is implemented there. Good recommendation on the change. Also, another question: Should the arg be separate for train and eval data loaders? I assumed not, but just wanted to confirm :). |
03a90f4 to
9a8fb7a
Compare
|
No I can't think of a scenario where one would want to drop_last in train and not in eval (or inversely) Thank you, merging |
Add an extra argument to
TrainingArgumentsthat would be passed on toTrainerfor use in DataLoader.I ran into a problem while using the
Trainerthis week and the GPU expecting the full batch size of vector inputs, and put a workaround in place in the dataset class I was using, but would be useful to have this as an optional argument.