Created by: still-wait
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)
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())