多分类focal loss 报错
Created by: x-ian-g
PaddlePaddle版本:1.6
- 训练信息 1)单机单卡 2)显存信息 3)Operator信息 报错信息 Traceback (most recent call last): File "run_classifier.py", line 403, in main(args) File "run_classifier.py", line 114, in main is_regression=args.is_regression) File "/ssd2/xiangjing/beta/ERNIE_2.0/finetune/classifier.py", line 110, in create_model x=logits, label=labels, fg_num=fg_num, gamma=2., alpha=0.25) File "/home/users/xiangjing/opt/mms-hpc-devel-pd-gpu-97/lib/python2.7/site-packages/paddle/fluid/layers/detection.py", line 436, in sigmoid_focal_loss outputs={"Out": out}) File "/home/users/xiangjing/opt/mms-hpc-devel-pd-gpu-97/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "/home/users/xiangjing/opt/mms-hpc-devel-pd-gpu-97/lib/python2.7/site-packages/paddle/fluid/framework.py", line 1780, in append_op attrs=kwargs.get("attrs", None)) File "/home/users/xiangjing/opt/mms-hpc-devel-pd-gpu-97/lib/python2.7/site-packages/paddle/fluid/framework.py", line 1173, in init self.desc.infer_shape(self.block.desc) paddle.fluid.core_avx.EnforceNotMet: Invoke operator sigmoid_focal_loss error. Python Call stacks: File "/home/users/xiangjing/opt/mms-hpc-devel-pd-gpu-97/lib/python2.7/site-packages/paddle/fluid/framework.py", line 1780, in append_op attrs=kwargs.get("attrs", None)) File "/home/users/xiangjing/opt/mms-hpc-devel-pd-gpu-97/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "/home/users/xiangjing/opt/mms-hpc-devel-pd-gpu-97/lib/python2.7/site-packages/paddle/fluid/layers/detection.py", line 436, in sigmoid_focal_loss outputs={"Out": out}) File "/ssd2/xiangjing/beta/ERNIE_2.0/finetune/classifier.py", line 110, in create_model x=logits, label=labels, fg_num=fg_num, gamma=2., alpha=0.25) File "run_classifier.py", line 114, in main is_regression=args.is_regression) File "run_classifier.py", line 403, in main(args) C++ Call stacks: Enforce failed. Expected fg_dims.size() == 1, but received fg_dims.size():2 != 1:1.
代码信息: finetune/classifier.py 将 softmax_with_cross_entropy 改为 函数 fluid.layers.sigmoid_focal_loss,按照帮助文档http://www.caihongshenghuo.com/documentation/docs/zh/1.6/api_cn/layers_cn/sigmoid_focal_loss_cn.html 的写法,报错如上。 fg_num = fluid.layers.data(name='fg_num', shape=[1], dtype='int32') focal_loss, probs = fluid.layers.sigmoid_focal_loss(x=logits, label=labels, fg_num=fg_num, gamma=2., alpha=0.25)