mlx.nn.losses.huber_loss

目录

mlx.nn.losses.huber_loss#

class huber_loss(inputs: array, targets: array, delta: float = 1.0, reduction: Literal['none', 'mean', 'sum'] = '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}\]
参数:
  • 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'.

返回:

The computed Huber loss.

返回类型:

array