identity_loss¶
- paddle.fluid.layers.loss.identity_loss(x, reduction='none')[source]
Marks a tensor as being part of the loss calculation for IPU.
This function should be called 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)\]- Parameters
x (Variable) – The calculated loss
Tensor
.reduction (str|int) – Reduce the loss output. Supported string values are: ‘mean’, ‘sum’, ‘none’ the corresponding int values are 0, 1, 2 respectively. The default value is “none”.
- Returns
The loss
Tensor
with the specified reduction applied.- Return type
Variable
Examples
import paddle.fluid as fluid import paddle paddle.enable_static() loss = fluid.data(name="loss", shape=[-1, 1], dtype="float32") out = fluid.layers.identity_loss(loss, reduction=1)