PaddleClas
PaddleClas copied to clipboard
feat: add 2 weight functions in multi-label
根据 https://github.com/PaddlePaddle/PaddleClas/issues/2951 新增两个 ratio2weight 函数。代码里延续论文中的命名,所以原 ratios2weight
改为 ratios2weight_1
。
Type 3 示例:
# loss function config for traing/eval process
Loss:
Train:
- MultiLabelLoss:
weight: 1.0
weight_type: 3
weight_alpha: 1 # float
weight_ratio: True
size_sum: True
Eval:
- MultiLabelLoss:
weight: 1.0
weight_type: 3
weight_alpha: 1 # float
weight_ratio: True
size_sum: True
Type 2/1 示例:
# loss function config for traing/eval process
Loss:
Train:
- MultiLabelLoss:
weight: 1.0
weight_type: 2
weight_ratio: True
size_sum: True
Eval:
- MultiLabelLoss:
weight: 1.0
weight_type: 2
weight_ratio: True
size_sum: True
但是 https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/ppcls/loss/dmlloss.py 中 import 了 ratio2weight
这个函数,目前的解决方案是在 dmlloss 中开启 weight_type 和 weight_alpha 这两个参数,与 multilabelloss 中保持一致,然后计算对应的 loss。
Thanks for your contribution!