-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
dim, | ||
ignore_idx, | ||
lbl); | ||
if (lbl == ignore_idx) { |
There was a problem hiding this comment.
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还需要吗?
There was a problem hiding this comment.
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
与否走不同分支的
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Others
PR changes
OPs
Describe
修复问题描述:
IgnoreIndex
仅在ignore_index
取值范围在[0, dim)时才生效,但是当某个label
值超出了边界,ignore_index
等于该label
,这种情况下是应该仍然能正常计算。虽然当前的计算逻辑在结果上不会出错,但逻辑上仍是有问题的,且模板参数IgnoreIndex
是没有必要的.assert
在release模式下无法生效,且需要更全面的报错信息,因此将assert
改为PADDLE_ENFORCE