l2_loss

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

Compute the loss of element-wise squared error.

The L2Loss function is defined as:

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

Examples:

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

dragon.Tensor The output tensor.