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

reimplement paddle.nn.functional.sigmoid_focal_loss #27748

Merged
merged 6 commits into from
Oct 9, 2020

Conversation

FlyingQianMM
Copy link
Contributor

@FlyingQianMM FlyingQianMM commented Sep 30, 2020

PR types

New features

PR changes

OPs

Describe

The paddle.nn.functional.sigmoid_focal_loss is implemented by alias of paddle.fluid.layers.sigmod_focal_loss before, now it is reimplement by composing the sigmoid and binary_cross_entropy_with_logits ops.

chinese pr: PaddlePaddle/docs#2751
image
image
image

@paddle-bot-old
Copy link

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

Args:
logit (Tensor): The input prediction tensor. 2-D tensor with shape: [N, *],
N is batch_size, `*` means number of additional dimensions. The ``logit``
is usually the output of a convolution layer. Available dtype is float32, float64.
Copy link
Contributor

Choose a reason for hiding this comment

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

是否支持多维的tensor的输入了?* 表示额外的维度,* 有可能是一维或者多维的信息

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已经去掉2-D tensor的描述。谢谢~

a 1-D Tensor whose shape is `[1, ]`. The data type is float32, float64.
For object detection task, it is the the number of positive samples.
If set to None, the focal loss will not be normalized.
alpha(int|float): Hyper-parameter to balance the positive and negative example,
Copy link
Contributor

Choose a reason for hiding this comment

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

因为有默认值,因此是optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已加上optional。谢谢~

If set to None, the focal loss will not be normalized.
alpha(int|float): Hyper-parameter to balance the positive and negative example,
it should be between 0 and 1. Default value is set to 0.25.
gamma(int|float): Hyper-parameter to modulate the easy and hard examples.
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已加上,谢谢~


import paddle

paddle.disable_static()
Copy link
Contributor

Choose a reason for hiding this comment

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

尝试一下是否可以去掉disable_static,现在默认打开的是动态图

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已经去掉,可以正常运行。谢谢~

Copy link
Contributor

@TCChenlong TCChenlong left a comment

Choose a reason for hiding this comment

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

LGTM

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

@FlyingQianMM FlyingQianMM merged commit 7ecbc46 into PaddlePaddle:develop Oct 9, 2020
@FlyingQianMM FlyingQianMM deleted the remove_focal_loss branch December 28, 2020 11:16
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.

3 participants