Skip to content

Conversation

@HydrogenSulfate
Copy link
Contributor

PR types

Function optimization

PR changes

APIs

Describe

  1. 更新cross_entropy边界检查时的报错代码,让输出的错误信息更清晰
  • label超出上界的case

    import paddle logits = paddle.uniform(shape=[1, 10]) label = paddle.to_tensor([100], dtype='int64') loss = paddle.nn.functional.cross_entropy(input=logits, label=label) # ---输出--- Traceback (most recent call last): File "xxx/ce_loss_optimize.py", line 31, in <module> loss = paddle.nn.functional.cross_entropy(input=logits, label=label) File "xxx/python3.7/site-packages/paddle/nn/functional/loss.py", line 1662, in cross_entropy format(label_max.item())) ValueError: Target 100 is out of upper bound.
  • label超出下界的case

    import paddle logits = paddle.uniform(shape=[1, 10]) label = paddle.to_tensor([-2], dtype='int64') loss = paddle.nn.functional.cross_entropy(input=logits, label=label) # ---输出--- Traceback (most recent call last): File "xxx/ce_loss_optimize.py", line 35, in <module> loss = paddle.nn.functional.cross_entropy(input=logits, label=label) File "xxx/python3.7/site-packages/paddle/nn/functional/loss.py", line 1659, in cross_entropy format(label_min.item())) ValueError: Target -2 is out of lower bound.
@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@chajchaj chajchaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@XiaoguangHu01 XiaoguangHu01 merged commit a7acfc5 into PaddlePaddle:develop Mar 1, 2022
@HydrogenSulfate HydrogenSulfate deleted the fix_ce_output branch March 2, 2022 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants