From 4b96ae62b4466cf271fcc1a9abd9248e4f6d9abe Mon Sep 17 00:00:00 2001 From: HydrogenSulfate <490868991@qq.com> Date: Sun, 15 Aug 2021 16:33:23 +0800 Subject: [PATCH] Update loss.py --- python/paddle/nn/functional/loss.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index 93c1820593e..46ff6bb5fb4 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1811,7 +1811,9 @@ def cross_entropy(input, .format(input.shape[-1], weight.shape[-1])) valid_label = paddle.where( label == ignore_index, - paddle.zeros([1], dtype=label.dtype), label) + paddle.zeros( + [1], dtype=label.dtype), + label) if (len(paddle.nonzero(valid_label < 0)) > 0) or ( len(paddle.nonzero(valid_label >= input.shape[-1])) > 0): invalid_label = paddle.gather_nd( -- GitLab