smooth_l1_loss

dragon.losses.smooth_l1_loss(
  inputs,
  beta=1.0,
  reduction='mean',
  **kwargs
)[source]

Compute the loss of element-wise error transited from L1 and L2. [Girshick, 2015].

The SmoothL1Loss function is defined as:

\[\text{SmoothL1Loss}(x, y) = \begin{cases} 0.5 * (x - y)^{2} / beta, & \text{ if } |x - y| < beta \\ |x - y| - 0.5 * beta, & \text{ otherwise } \end{cases} \]

Examples:

x = dragon.constant([1., 2., 3.])
y = dragon.constant([0., 0., 0.])
print(dragon.losses.smooth_l1_loss([x, y]))  # 1.5
Parameters:
  • inputs (Sequence[dragon.Tensor]) The tensor input and target.
  • beta (float, optional, default=1.0) The transition point from L1 to L2 loss
  • reduction ({'none', 'sum', 'mean'}, optional) The reduction method.
Returns:

dragon.Tensor The output tensor.