paddle.incubate. identity_loss ( x, reduction='none' ) [source]

Marks a tensor as being part of the loss calculation for IPU.

This operator is used to handle on the (final) loss of a model so that it is used as the start of backpropagation.

When reduction is none, return raw Out.

When reduction is mean, return

\[Out = MEAN(Out)\]

When reduction is sum, return

\[Out = SUM(Out)\]
  • x (Variable) – The input tensor. The shapes is [N, *], where N is batch size and * means any number of additional dimensions. It’s data type should be float32, float64 on CPU and float16, float32 on IPU.

  • reduction (str|int, optional) – Reduce the loss output. Supported string values are: ‘sum’, ‘mean’, ‘none’ the corresponding int values are 0, 1, 2 respectively. The default value is “none”.


The loss Tensor with the specified reduction applied.

Return type



>>> import paddle
>>> paddle.enable_static()
>>> loss ="loss", shape=[-1, 1], dtype="float32")
>>> out = paddle.incubate.identity_loss(loss, reduction=1)