l1_loss

dragon.losses.l1_loss(
  inputs,
  reduction='mean',
  **kwargs
)[source]

Compute the element-wise absolute value difference.

The L1Loss function is defined as:

\[\text{L1Loss}(x, y) = |x - y| \]

Examples:

logit = dragon.constant([1., 2., 3.])
target = dragon.constant([0., 0., 0.])
print(dragon.losses.l1_loss([logit, target]))  # 2.0
Parameters:
  • inputs (Sequence[dragon.Tensor]) – The tensor logit and target.
  • reduction ({'none', 'sum', 'mean'}, optional) – The reduction method.
Returns:

dragon.Tensor – The output tensor.