diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index c67f578df22f72292adb9dcc5ee62a31a063f72b..831d5e9207d0d8ab7796b4cfdba982fab3fd3359 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1806,8 +1806,8 @@ def cross_entropy(input, valid_label = paddle.where(label == ignore_index, paddle.zeros_like(label), label) - ignore_weight_mask = paddle.cast( - (label != ignore_index), input.dtype) + ignore_weight_mask = paddle.cast((label != ignore_index), + input.dtype) if ignore_weight_mask.ndim > 1 and ignore_weight_mask.shape[ -1] == 1: ignore_weight_mask = paddle.squeeze(ignore_weight_mask, -1)