-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Fix] Add avg_non_ignore in cross entropy loss #1409
[Fix] Add avg_non_ignore in cross entropy loss #1409
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.
Codecov Report
@@ Coverage Diff @@
## master #1409 +/- ##
==========================================
- Coverage 90.39% 90.26% -0.14%
==========================================
Files 133 136 +3
Lines 7906 7961 +55
Branches 1318 1326 +8
==========================================
+ Hits 7147 7186 +39
- Misses 536 550 +14
- Partials 223 225 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
* [Fix] Add avg_non_ignore in cross entropy loss * [Fix] Add avg_non_ignore in cross entropy loss * add docstring * fix ut * fix docstring and comments * fix * fix bce * fix avg_factor in BCE and add more ut * add avg_non_ignore * add more ut * fix part of ut * fix part of ut * test avg_non_ignore would not affect ce/bce when reduction none/sum * test avg_non_ignore would not affect ce/bce when reduction none/sum/mean * re-organize ut * re-organize ut * re-organize ut * re-organize hardcode case * fix parts of comments * fix another parts of comments * fix
* [Fix] Add avg_non_ignore in cross entropy loss * [Fix] Add avg_non_ignore in cross entropy loss * add docstring * fix ut * fix docstring and comments * fix * fix bce * fix avg_factor in BCE and add more ut * add avg_non_ignore * add more ut * fix part of ut * fix part of ut * test avg_non_ignore would not affect ce/bce when reduction none/sum * test avg_non_ignore would not affect ce/bce when reduction none/sum/mean * re-organize ut * re-organize ut * re-organize ut * re-organize hardcode case * fix parts of comments * fix another parts of comments * fix
Motivation
Right now, MMSegmentation do not support
ignore_index
in loss average over non-ignored elements in CE loss.fix #578.
old pr: #1388.
In old PR: #578, the author fixed it while it left a bug if all labels in one image is
ignore_index
,avg_factor
would be zero and ZeroDivisionError would be rasied inweight_reduce_loss
function.Usage
Just take fcn_unet_s5-d16_128x128_40k_chase_db1.py, its base config for example:
original config:
Just add
ignore_index
in decoder head or auxiliary head and addavg_non_ignore=True
:avg_non_ignore=True
avg_non_ignore=False