-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix the API of bce loss and add functional API binary_cross_entropy #26012
Conversation
Thanks for your contribution! |
python/paddle/nn/layer/loss.py
Outdated
print(output.numpy()) # [0.65537095] | ||
paddle.enable_static() | ||
|
||
# static mode |
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.
No need to show static graph demo code.
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 exist static mode demo before. I think keep it will be batter
describe记得修改 |
If :attr:`weight` is None, the loss is: | ||
|
||
.. math:: | ||
Out = -1 * (label * log(input) + (1 - label) * log(1 - input)) | ||
|
||
If :attr:`reduction` set to ``'none'``, the unreduced loss is: | ||
If :attr:`reduction` set to ``'none'``, the interface will return the original loss `Out`. |
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.
interface用法会不会有点奇怪,改为operation?
batch element. If given, has to be a Tensor of size nbatch and the data type | ||
is float32, float64. Default is ``'None'``. | ||
reduction (str, optional): Indicate how to average the loss by batch_size, | ||
the candicates are ``'none'`` | ``'mean'`` | ``'sum'``. |
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.
LGTM
output = paddle.nn.functional.binary_cross_entropy(input, label) | ||
print(output.numpy()) # [0.65537095] | ||
paddle.enable_static() | ||
|
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 types
Others
PR changes
APIs
Describe
fix the API of bce loss and add functional API binary_cross_entropy.