l1_loss

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

Compute the loss of element-wise absolute value difference.

The L1Loss function is defined as:

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

Examples:

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

dragon.Tensor – The output tensor.