-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
Default DataLoader shuffle=True
for training
#5623
Default DataLoader shuffle=True
for training
#5623
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hello @werner-duvaud, thank you for submitting a 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:
- ✅ Verify your PR is up-to-date with upstream/master. If your PR is behind upstream/master an automatic GitHub actions rebase may be attempted by including the /rebase command in a comment body, or by running the following code, replacing 'feature' with the name of your local branch:
git remote add upstream https://github.com/ultralytics/yolov5.git
git fetch upstream
git checkout feature # <----- replace 'feature' with local branch name
git merge upstream/master
git push -u origin -f
- ✅ Verify all Continuous Integration (CI) checks are passing.
- ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." -Bruce Lee
@werner-duvaud one conflict here is --rect, which will force single-image (no mosaic) minimum rectangular batch sizes. This precomputes batch size dimensions based on the dataset sorted by aspect ratio. val.py uses this by default for example, but it's a setting we also have in train.py also. So we need something like |
@glenn-jocher Thanks! I have added The downside could be that by passing shuffle = True to (I have rebased to make the CI happy) |
@werner-duvaud yes good idea. Can you all a logger warning for this case? EDIT: added this update and a bit of cleanup myself in 89abf9e |
shuffle=True
for training
for more information, see https://pre-commit.ci
@werner-duvaud cleaned this up a bit and added a rect-shuffle conflict warning and handling. Evaluating now on VOC. Also linked to #2582 to close that (long-running) TODO. |
@werner-duvaud PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐ |
@werner-duvaud I evaluated this PR against master on VOC finetuning for 50 epochs, and the results show a slight improvement in most metrics and losses, particularly in objectness loss and mAP@0.5, perhaps indicating that the shuffle addition may help delay overtraining. |
* Fix shuffle DataLoader argument * Add shuffle argument * Disable shuffle when rect * Cleanup, add rect warning * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Cleanup2 * Cleanup3 Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
If the issue #5622 is relevant, I have added the
shuffle
argument tocreate_dataloader
. It defaults to False and is set to True only when creating the training dataloader.This shuffle parameter is then passed to the
DataLoader
orDistributedSampler
to maintain a coherent behaviour. (in pytorch doc, shuffle defaults to False for DataLoader and to True for DistributedSampler)🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Enhanced data loading with shuffle option for YOLOv5 training.
📊 Key Changes
train.py
now passes ashuffle=True
argument to the data loader, enabling data shuffling during training.create_dataloader
function inutils/datasets.py
now accepts ashuffle
argument.rect=True
) and shuffling are made mutually exclusive to avoid potential conflicts.DataLoader
andInfiniteDataLoader
to allow attribute updates, with a conditional use ofDistributedSampler
based on rank.utils/datasets.py
for clearer code structure.🎯 Purpose & Impact