l2_loss

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

Compute the element-wise squared error.

The L2Loss function is defined as:

\[\text{L2Loss}(x, y) = (x - y)^{2} \]

Examples:

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

dragon.Tensor – The output tensor.