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

Add paddle.nn.SmoothL1Loss #26398

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

yghstill
Copy link
Contributor

@yghstill yghstill commented Aug 18, 2020

PR types

New features

PR changes

APIs

Describe

add paddle.nn.SmoothL1Loss. This operator is calculate smooth_l1_loss. Creates a criterion that uses a squared term if the absolute element-wise error falls below 1 and an L1 term otherwise. In some cases it can prevent exploding gradients. Also known as the Huber loss.

class:

class paddle.nn.SmoothL1Loss(reduction='mean', delta=1.0, name=None)

functioanl:

def paddle.nn.functioanl.smooth_l1_loss(input, label, reduction='mean', delta=1.0, name=None)

docs
image
image
image

Examples:

           import paddle
            import numpy as np
            paddle.disable_static()
            input_data = np.random.rand(3,3).astype("float32")
            label_data = np.random.rand(3,3).astype("float32")
            input = paddle.to_tensor(input_data)
            label = paddle.to_tensor(label_data)
            loss = paddle.nn.SmoothL1Loss()
            output = loss(input, label)
            print(output.numpy())

@paddle-bot-old
Copy link

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

Copy link
Contributor

@yaoxuefeng6 yaoxuefeng6 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

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

lgtm
great to know no c++ op is introduced and huber_loss api is reused.

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@jerrywgz jerrywgz merged commit e52e794 into PaddlePaddle:develop Aug 20, 2020
@yghstill yghstill deleted the add_smooth_l1_loss_v2 branch August 20, 2020 02:48
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.

5 participants