-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Feature]: Support empty tensor in MMSyncBN #1205
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1205 +/- ##
==========================================
- Coverage 69.14% 68.94% -0.20%
==========================================
Files 162 162
Lines 10746 10776 +30
Branches 1978 1988 +10
==========================================
Hits 7430 7430
- Misses 2927 2957 +30
Partials 389 389
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Conflicts: mmcv/ops/sync_bn.py
The performance in MMDetection has been verified through open-mmlab/mmdetection#6132 |
Merged as the accuracy of the final commit should be guaranteed. |
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
In detection models trained by strong augmentation, the RoIHead may be trained with empty proposals if the objects are all contained in the cropped images, this will cause failure because the current MMSyncBN does not support training with empty tensor.
Related discussion/implementations:
Modification
batch_flag
to indicate the global batch size because when the global batch is zero, we need to make the momentum to be zero to skip the update ofrunning_mean/running_var
.stats_mode
to produce more accurate batch statistics when empty tensor might be given.flatten
rather thanview(-1, ...)
when reshaping the tensor which better handles empty tensor.empty/empty_like
tozeros/zeros_like
, because thetorch.empty()
returns uninitialized values of tensor, which might contain unexpected values other than zeros. See related discussion in stackoverflow.BC-breaking (Optional)
The modification does not introduce changes that break the backward compatibility of the downstream repos?
It support the new strong baseline.
Use cases (Optional)
Inference with empty tensor is supported, see the added unit tests.
Checklist