-
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
【Paddle Hackathon No.11】 #45595
【Paddle Hackathon No.11】 #45595
Conversation
prog = paddle.static.Program() | ||
startup_prog = paddle.static.Program() | ||
with paddle.static.program_guard(prog, startup_prog): | ||
input = paddle.static.data(name='input', |
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.
For test cases in static mode, you'd better add some cases that paddle.static.data
creates data layer that has dynamic shape to ensure that it works as expected.
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.
I add the new test cases of checking data shape in static mode. but I'm not quite sure about it.
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.
I mean, you can create an data layer with shape [-1, -1]
and feed it with an array with shape [3, 4]
or [5, 6]
.
Or create a data layer with shape [-1, 3,4]
and feed it with an array with shape [7, 3, 4]
I the rank and all the static size matches, it is compatible.
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.
- Weight should be for each class, instead of each example. The main logic is different than the design in RFC;
- use paddle.shape(tensor) to get actual shape so it can work with dynamic shape in static mode;
- add test cases for dynamic shape in static mode;
- The documentation should be modified.
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.
The computation does not agree with the formula in the documentation.
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
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.
The CI system says
2022-09-26 16:20:48 0. It is recommended to use 'np.testing.assert_allclose' and 'np.testing.array_equal' instead of 'self.assertTrue(np.allclose(...))' and 'self.assertTrue(np.array_equal(...))'.
Also, I suggest a simpler implementation to pick N
values from weight of shape (C,)
. See the comment above.
Done, change 'self.asserrTrue' to 'np.testing.assert_allclose' |
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
python/paddle/nn/functional/loss.py
Outdated
reduction='mean', | ||
name=None): | ||
r""" | ||
Measures a multi-class classification hinge loss (margin-based loss) between input :math:`input` (a 2D mini-batch `Tensor`, in shape (N, C), |
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.nn.MultiMarginLoss做修改吧
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.
已修改
python/paddle/nn/layer/loss.py
Outdated
|
||
label: 1-D Tensor, the shape is [N,]. | ||
|
||
output: scalar. If :attr:`reduction` is ``'none'``, then same shape as the input. |
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.
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.
应该是和 label 同一维度,能否合入后,我再发起 pr 修改
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.
文档修改可以在commit后加上 ; test=document_fix
跳过代码检查的CI
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.
已修改
margin: float = 1.0, | ||
weight=None, | ||
reduction="mean", | ||
name=None): |
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.
in order to have rfc same with code, need to modify paddle.nn.MultiMarginLoss( p:int = 1, margin:float=1.0, weight (Tensor,可选), reduction(str,可选), name=None) -> None:
in rfc 命名与参数设计
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.
重新提起 pr 修改 rfc
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 docs
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
@yangguohao 啊哦,示例代码挂了,重新修改一下吧,可以采用 |
该问题应由 #46712 导致,最近的只要修改了文档的 PR 均存在此问题,#46944 merge 后应可解决本问题 @yangguohao 需要 #46944 merge 后,重新 merge 下 develop |
PR types
New features
PR changes
APIs
Describe
解决 issues #44073 (comment)
添加了paddle.nn.MultiMarginLoss以及paddle.nn.functional.multi_margin_loss的函数
设计文档 PaddlePaddle/community#171
中文文档 PaddlePaddle/docs#5262