Skip to content

Conversation

@LutaoChu
Copy link
Contributor

@LutaoChu LutaoChu commented Aug 9, 2021

修复weighted cross entropy的bug.
该问题也涉及paddle cross entropy op的问题,需要同步进行修复,修复代码参考最下方

报错日志:
image

Bug复现代码:

import paddle
from paddleseg.models.losses import CrossEntropyLoss

input_data = paddle.rand(shape=[4, 7, 125, 125])
label_data = paddle.randint(0, 7, shape=[4, 125, 125], dtype="int64")
label_data[0, 0, 0] = 255
print(paddle.unique(label_data))
weight = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]

loss = CrossEntropyLoss(weight=weight)
out = loss(input_data, label_data)
print(out)

按下面的代码修改你的paddle cross entropy op源码(后续我们也会将该修复提交至paddle):
image

按上述方法修复后,Bug复现代码不再报错。

如何寻找paddle源码?

1 寻找python所在位置
2 进入安装的paddle代码所在位置
示例:
image

@LutaoChu LutaoChu merged commit c8acc1d into PaddlePaddle:develop Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants