You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fix] Add avg_non_ignore in cross entropy loss (open-mmlab#1409)
* [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
Copy file name to clipboardExpand all lines: docs/en/tutorials/training_tricks.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,3 +68,23 @@ model = dict(
68
68
In this way, `loss_weight` and `loss_name` will be weight and name in training log of corresponding loss, respectively.
69
69
70
70
Note: If you want this loss item to be included into the backward graph, `loss_` must be the prefix of the name.
71
+
72
+
## Ignore specified label index in loss calculation
73
+
74
+
In default setting, `avg_non_ignore=False` which means each pixel counts for loss calculation although some of them belong to ignore-index labels.
75
+
76
+
For loss calculation, we support ignore index of certain label by `avg_non_ignore` and `ignore_index`. In this way, the average loss would only be calculated in non-ignored labels which may achieve better performance, and here is the [reference](https://github.com/open-mmlab/mmsegmentation/pull/1409). Here is an example config of training `unet` on `Cityscapes` dataset: in loss calculation it would ignore label 0 which is background and loss average is only calculated on non-ignore labels:
0 commit comments