pub fn huber_loss<T: Reduce<AllAxes>>(
    pred: T,
    targ: T::NoTape,
    delta: T::Dtype
) -> T::Reduced
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:

  1. if |x - y| < delta: 0.5 * (x - y)^2
  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);