smooth_l1

smooth_l1(data=None, scalar=_Null, out=None, name=None, **kwargs)

Calculate Smooth L1 Loss(lhs, scalar) by summing

(13)\[\begin{split}f(x) = \begin{cases} (\sigma x)^2/2,& \text{if }x < 1/\sigma^2\\ |x|-0.5/\sigma^2,& \text{otherwise} \end{cases}\end{split}\]

where \(x\) is an element of the tensor lhs and \(\sigma\) is the scalar.

Example:

smooth_l1([1, 2, 3, 4]) = [0.5, 1.5, 2.5, 3.5]
smooth_l1([1, 2, 3, 4], scalar=1) = [0.5, 1.5, 2.5, 3.5]

Defined in src/operator/tensor/elemwise_binary_scalar_op_extended.cc:L108

Parameters:
data : ndarray

source input

scalar : float

scalar input

out : ndarray, optional

The output ndarray to hold the result.

Returns:
out : ndarray or list of ndarrays

The output of this function.