Skip to main content

ClikaRT::ops::huber_loss

function

huber_loss()

Tensor huber_loss(
    Tensor input,
    Tensor target,
    Reduction reduction = Reduction::Mean,
    double delta = 1.0
)

Huber loss: quadratic near zero, linear past the delta knee.

i={12(xiyi)2xiyiδδ(xiyi12δ)otherwise\ell_i = \begin{cases} \tfrac{1}{2}(x_i - y_i)^2 & |x_i - y_i| \le \delta \\ \delta\,(|x_i - y_i| - \tfrac{1}{2}\delta) & \text{otherwise} \end{cases}

Parameters

  • input: predictions; float dtype.
  • target: ground truth; same shape as input.
  • reduction: None / Mean / Sum; default Mean.
  • delta: the quadratic-to-linear knee; default 1.0.

Returns: the loss (0-D under Mean/Sum).

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) on an input/target shape mismatch.

Declared in ClikaRT/compute/ops.h, line 2956