From 05eaa9bcb58b719b0edca895dc5a9c75457ece75 Mon Sep 17 00:00:00 2001 From: HydrogenSulfate <490868991@qq.com> Date: Sun, 15 Aug 2021 16:00:39 +0800 Subject: [PATCH] Update loss.py --- python/paddle/nn/functional/loss.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index fe649042418..0c0e4ec938b 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1811,8 +1811,7 @@ def cross_entropy(input, .format(input.shape[-1], weight.shape[-1])) valid_label = paddle.where( label == ignore_index, - paddle.to_tensor( - 0, dtype=label.dtype), + paddle.zeros([1], dtype=label.dtype), dtype=label.dtype), label) if (len(paddle.nonzero(valid_label < 0)) > 0) or ( len(paddle.nonzero(valid_label >= input.shape[-1])) > 0): -- GitLab