mlx.nn.losses.hinge_loss

Contents

mlx.nn.losses.hinge_loss#

class hinge_loss(inputs: array, targets: array, reduction: Literal['none', 'mean', 'sum'] = 'none')#

Computes the hinge loss between inputs and targets.

hinge(y,ypred)=max(0,1yypred)
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