未验证 提交 a7acfc5b 编写于 作者: H HydrogenSulfate 提交者: GitHub

update error_string when target is out of bound (#40001)

上级 468a2a17
......@@ -1667,11 +1667,11 @@ def cross_entropy(input,
label_min = paddle.min(valid_label)
label_max = paddle.max(valid_label)
if label_min < 0:
raise ValueError("label should not out of bound, but got{}".
format(label_min))
raise ValueError("Target {} is out of lower bound.".format(
label_min.item()))
if label_max >= input.shape[axis]:
raise ValueError("label should not out of bound, but got{}".
format(label_max))
raise ValueError("Target {} is out of upper bound.".format(
label_max.item()))
if core.is_compiled_with_npu() or core.is_compiled_with_mlu():
_, _, out = _C_ops.softmax_with_cross_entropy(
input, label, 'soft_label', soft_label, 'ignore_index',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册