From 52804cd8aa281141e40b87f5b9e19652b439b196 Mon Sep 17 00:00:00 2001 From: HydrogenSulfate <490868991@qq.com> Date: Mon, 16 Aug 2021 14:27:22 +0800 Subject: [PATCH] Update loss.py --- python/paddle/nn/functional/loss.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index c225fa84948..14501012062 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1806,7 +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