# mlx.nn.losses.huber_loss — MLX 0.0.7 documentation

Skip to main content
`Ctrl`+`K`

# mlx.nn.losses.huber_loss

class mlx.nn.losses.huber_loss(inputs: array, targets: array, delta: float = 1.0, reduction: str = 'none')

  Computes the Huber loss between inputs and targets.

  \[\begin{split}L_{\delta}(a) = \left\{ \begin{array}{ll} \frac{1}{2} a^2 & \text{for } |a| \leq \delta, \\ \delta \left( |a| - \frac{1}{2} \delta \right) & \text{otherwise.} \end{array} \right.\end{split}\]
  Parameters:

    - inputs (array) – The predicted values.

    - targets (array) – The target values.

    - delta (float , optional) – The threshold at which to change between L1 and L2 loss. Default: `1.0`.

    - reduction (str , optional) – Specifies the reduction to apply to the output: `'none'` | `'mean'` | `'sum'`. Default: `'none'`.

  Returns:

    The computed Huber loss.

  Return type:

    array