* [Fix] Fix the bug in binary_cross_entropy
Fix the bug in binary_cross_entropy
'label.max() <= 1' should mask out ignore_index, since the ignore_index often set as 255.
* [Fix] Fix the bug in binary_cross_entropy, add comments
As the ignore_index often set as 255, so the binary class label check should mask out ignore_index.
Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
* [Fix] Fix the bug in binary_cross_entropy
As the ignore_index often set as 255, so the binary class label check should mask out ignore_index.
Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
Co-authored-by: MeowZheng <meowzheng@outlook.com>
* [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] Fix the bug that when all pixels in an image is ignored, the accuracy calculation raises ZeroDivisionError
* use eps
* all close
* add ignore test
* add eps
* [Feature] add focal loss
* fix the bug of 'non' reduction type
* refine the implementation
* add class_weight and ignore_index; support different alpha values for different classes
* fixed some bugs
* fix bugs
* add comments
* modify test
* Update mmseg/models/losses/focal_loss.py
Co-authored-by: Junjun2016 <hejunjun@sjtu.edu.cn>
* update test_focal_loss.py
* modified the implementation
* Update mmseg/models/losses/focal_loss.py
Co-authored-by: Jerry Jiarui XU <xvjiarui0826@gmail.com>
* update focal_loss.py
Co-authored-by: Junjun2016 <hejunjun@sjtu.edu.cn>
Co-authored-by: Jerry Jiarui XU <xvjiarui0826@gmail.com>
* support reading class_weight from file in loss function
* add unit test of loss with class_weight from file
* minor fix
* move get_class_weight to utils