Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify DataLoader #1398

Closed
wants to merge 2 commits into from
Closed

Modify DataLoader #1398

wants to merge 2 commits into from

Conversation

myunghakLee
Copy link

@myunghakLee myunghakLee commented Jul 20, 2020

The DataLoader of the original code had a problem that the number of data had to be divided by Batchsize.
so often an error occurred.

Like this
("TypeError: forward() missing 1 required positional argument: 'x')
#1355
#1074

But add "drop_last = True" in DataLoader, the problem is fixed.

I tested this code in a "multi-GPU environment"

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhancements to DataLoader behavior in YOLOv3 training script.

📊 Key Changes

  • The DataLoader instances in training and testing now use the drop_last argument set to True.

🎯 Purpose & Impact

  • 🎯 Purpose: The modification ensures that any partial batches at the end of an epoch are discarded. This can be particularly useful when the neural network expects consistent batch sizes to maintain effective learning, as some layers or configurations might be sensitive to varying batch sizes.
  • 🔍 Impact: Users may experience more stable training, particularly when dealing with small datasets or datasets that do not divide evenly by the batch size. This change may slightly reduce the amount of data being used for training, as the last, potentially smaller batch from each epoch will be skipped.

Prev file have to adjust number  of dataset should be divided by batchsize.
But use "drop_last = True" in DataLoader The above conditions are no longer necessary
@glenn-jocher
Copy link
Member

@myunghakLee thanks for the feedback. You should be able to train and test any size datasets with any size batches without problem. On the train side, COCO 2017 train is 118287 images for example, and we've trained this with no problems at batch size 8, 16, 64, 96, 30, etc. The test set there is 5000 images, and the testing is run at the same batch-size at training, so there are combinations which are clearly not evenly divisible, yet still train and test correctly.

We also can not accept this PR for the simple reason that we want to test all images in the validation set, it would be an extremely poor design decision to drop images from validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants