mlx.nn.losses.l1_loss#

class mlx.nn.losses.l1_loss(predictions: array, targets: array, reduction: str = 'none')#

Computes the L1 loss between predictions and targets.

Parameters:
  • predictions (mx.array) – The predicted values.

  • targets (mx.array) – The target values.

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

Returns:

The computed L1 loss.

Return type:

mx.array