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

Fix the API of bce loss and add functional API binary_cross_entropy #26012

Merged
merged 8 commits into from
Aug 21, 2020

Conversation

ZHUI
Copy link
Collaborator

@ZHUI ZHUI commented Aug 6, 2020

PR types

Others

PR changes

APIs

Describe

fix the API of bce loss and add functional API binary_cross_entropy.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Aug 6, 2020

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

python/paddle/nn/layer/loss.py Outdated Show resolved Hide resolved
python/paddle/nn/layer/loss.py Outdated Show resolved Hide resolved
python/paddle/nn/layer/loss.py Outdated Show resolved Hide resolved
python/paddle/nn/layer/loss.py Outdated Show resolved Hide resolved
python/paddle/nn/layer/loss.py Outdated Show resolved Hide resolved
python/paddle/fluid/tests/unittests/test_bce_loss.py Outdated Show resolved Hide resolved
print(output.numpy()) # [0.65537095]
paddle.enable_static()

# static mode
Copy link
Contributor

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.

Copy link
Collaborator Author

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

@LutaoChu
Copy link
Contributor

PR types

Others

PR changes

Docs

Describe

PREVIEW THE DOCS, DON'T MERGE!

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`.
Copy link
Contributor

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'``.
Copy link
Contributor

Choose a reason for hiding this comment

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

| 要确定改成什么符号合适?

python/paddle/nn/functional/loss.py Outdated Show resolved Hide resolved
@ZHUI ZHUI changed the title fix the doc of bce loss fix the API of bce loss and add functional API binary_cross_entropy Aug 18, 2020
@ZHUI ZHUI changed the title fix the API of bce loss and add functional API binary_cross_entropy Fix the API of bce loss and add functional API binary_cross_entropy Aug 18, 2020
Copy link
Contributor

@wawltor wawltor left a comment

Choose a reason for hiding this comment

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

LGTM

@wawltor wawltor merged commit c10cf6d into PaddlePaddle:develop Aug 21, 2020
output = paddle.nn.functional.binary_cross_entropy(input, label)
print(output.numpy()) # [0.65537095]
paddle.enable_static()

Copy link
Contributor

Choose a reason for hiding this comment

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

这一行多余吧?

@ZHUI ZHUI deleted the bceloss branch September 14, 2020 09:32
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.

None yet

5 participants