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

Skip to main content
`Ctrl`+`K`

# mlx.nn.losses.hinge_loss

class mlx.nn.losses.hinge_loss(inputs: array, targets: array, reduction: str = 'none')

  Computes the hinge loss between inputs and targets.

  \[\text{hinge}(y, y_{\text{pred}}) = \max(0, 1 - y \cdot y_{\text{pred}})\]
  Parameters:

    - inputs (array) – The predicted values.

    - targets (array) – The target values. They should be -1 or 1.

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

  Returns:

    The computed hinge loss.

  Return type:

    array