oneflow.nn.functional.l1_loss(input, target, reduction='mean')Tensor

This operator computes the L1 loss between each element in input and target.

see L1Loss for details.

  • input (Tensor) – The input Tensor.

  • target (Tensor) – The target Tensor.

  • reduction (string, optional) – The reduce type, it can be one of “none”, “mean”, “sum”. Defaults to “mean”.


>>> import oneflow as flow
>>> import oneflow.nn.functional as F
>>> input = flow.randn(3, 4, requires_grad=True)
>>> target = flow.rand(3, 4, requires_grad=False)
>>> loss = F.l1_loss(input, target)
>>> loss.backward()