Function dfdx::losses::huber_loss
source · [−]Expand description
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| < delta
:0.5 * (x - y)^2
- otherwise:
delta * (|x - y| - 0.5 * delta)
Example
let x = Tensor1D::new([-1.0, -0.5]);
let y = Tensor1D::new([0.5, 0.5]);
let loss = huber_loss(x.traced(), y, 1.0);