From 0e048fc601ee33ea13303905b7dca3b0a58fb168 Mon Sep 17 00:00:00 2001 From: sneaxiy <32832641+sneaxiy@users.noreply.github.com> Date: Sat, 9 Apr 2022 10:59:32 +0800 Subject: [PATCH] fix cross entropy (#41541) --- python/paddle/nn/functional/loss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index 593cea2d2c..fb9c22edc6 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1905,7 +1905,7 @@ def cross_entropy(input, if reduction == "sum": return paddle.sum(out, name=name) elif reduction == "mean": - if ignore_index != -100: + if ignore_index >= 0: out_sum = paddle.sum(out, name=name) # for each label[i],set 1 or 0, according to ignore_index # mask[i]=0, if label[i]==ignore_index -- GitLab