From 11e9d4e348a6b89e3ee0f456e84867393930dcf6 Mon Sep 17 00:00:00 2001 From: HydrogenSulfate <490868991@qq.com> Date: Mon, 16 Aug 2021 19:00:28 +0800 Subject: [PATCH] Update loss.py --- python/paddle/nn/functional/loss.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index c67f578df22..831d5e9207d 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) -- GitLab