Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the logic and remove unnecessary template param #46623

Merged
merged 6 commits into from
Oct 13, 2022

Conversation

ZzSean
Copy link
Contributor

@ZzSean ZzSean commented Sep 29, 2022

PR types

Others

PR changes

OPs

Describe

修复问题描述:

  • 当前的模板参数IgnoreIndex仅在ignore_index取值范围在[0, dim)时才生效,但是当某个label值超出了边界,ignore_index等于该label,这种情况下是应该仍然能正常计算。虽然当前的计算逻辑在结果上不会出错,但逻辑上仍是有问题的,且模板参数IgnoreIndex是没有必要的.
  • assert在release模式下无法生效,且需要更全面的报错信息,因此将assert改为PADDLE_ENFORCE

@paddle-bot
Copy link

paddle-bot bot commented Sep 29, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

dim,
ignore_idx,
lbl);
if (lbl == ignore_idx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

前面PADDLE_ENFORCE里面已经判断了lbl == ignore_idx,这个if还需要吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

需要的,前面只是判断当前的lbl是否满足边界限制,即满足[0, dim)和lbl == ignore_idx两者其一。后续计算还是需要根据lbl == ignore_idx与否走不同分支的

Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM for PADDLE_ENFORCE

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

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

LGTM

@ZzSean ZzSean merged commit 450af30 into PaddlePaddle:develop Oct 13, 2022
@ZzSean ZzSean deleted the cross_entropy_fix branch November 7, 2022 03:00
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.

3 participants