Function dfdx::losses::smooth_l1_loss

source ·
pub fn smooth_l1_loss<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>>(
    pred: Tensor<S, E, D, T>,
    targ: Tensor<S, E, D>,
    delta: impl Into<f64>
) -> Tensor<Rank0, E, D, T>
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:

  1. if |x - y| < beta: 0.5 * (x - y)^2 / beta
  2. otherwise: |x - y| - 0.5 * beta