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

Skip to main content
`Ctrl`+`K`

# mlx.nn.losses.nll_loss

class mlx.nn.losses.nll_loss(inputs: array, targets: array, axis: int = - 1, reduction: str = 'none')

  Computes the negative log likelihood loss.

  Parameters:

    - inputs (array) – The predicted distribution in log space.

    - targets (array) – The target values.

    - axis (int , optional) – The distribution axis. Default: `-1`.

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

  Returns:

    The computed NLL loss.

  Return type:

    array