Function dfdx::losses::smooth_l1_loss
source · [−]Expand description
Smooth l1 loss (closely related to Huber Loss)
uses absolute error when the error is higher than beta
, and squared error when the
error is lower than beta
.
It computes:
- if
|x - y| < beta
:0.5 * (x - y)^2 / beta
- otherwise:
|x - y| - 0.5 * beta
Example
let x = Tensor1D::new([-1.0, -0.5]);
let y = Tensor1D::new([0.5, 0.5]);
let loss = smooth_l1_loss(x.traced(), y, 1.0);