Skip to content

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.

@yghstill yghstill force-pushed the add_smooth_l1_loss_v2 branch from 37a4967 to ee872f7 Compare August 18, 2020 09:45
@yghstill yghstill force-pushed the add_smooth_l1_loss_v2 branch from ee872f7 to c22eb0c Compare August 19, 2020 01:52
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