-
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
add nn.functional.normalize API for API2.0, fix L1Loss API typo #26269
Conversation
Thanks for your contribution! |
python/paddle/nn/functional/norm.py
Outdated
axis (int, optional): The axis on which to apply normalization. If `x` is 1-D tensor, `axis` is fixed to 0. If `axis < 0`, \ | ||
the dimension to normalization is rank(X) + axis. -1 is the last dimension. | ||
epsilon (float, optional): Small float added to denominator to avoid dividing by zero. Default is 1e-12. | ||
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. |
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.
name 对齐
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.
done
python/paddle/nn/functional/norm.py
Outdated
|
||
import paddle | ||
import paddle.nn.functional as F | ||
import numpy as np |
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.
import numpy as np 放在第一行import, pep8规范
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.
done. 是因为按字母序吗?
x = paddle.to_variable(self.input_np2) | ||
y = F.normalize(x) | ||
self.assertTrue(np.allclose(y.numpy(), self.expected3)) | ||
|
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.
eps单测是否需要增加一个?
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.
eps用来防止除零,上面这行就是验证除零时eps是否生效了,输入特意构造了全零tensor
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.
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.
LGTM
PR types
New features,Bug fixes
PR changes
APIs,Docs
Describe
1 add nn.functional.normalize API for API2.0,
2 fix L1Loss API typo: x -> input, remove 'scalar'