From f3d315ae5fc4e4023dad64b1454d748c3237f191 Mon Sep 17 00:00:00 2001 From: HydrogenSulfate <490868991@qq.com> Date: Sun, 15 Aug 2021 14:00:17 +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 270d4e71db4..b63b2e9983b 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1818,13 +1818,13 @@ def cross_entropy(input, len(paddle.nonzero(valid_label >= input.shape[-1])) > 0): invalid_label = paddle.gather_nd( input, paddle.nonzero(valid_label < 0)) - if invalid_label.numel() > 0: + if paddle.numel(invalid_label) > 0: raise ValueError( "Target({}) is out of class_dimension's lower bound({})". format(invalid_label[0], 0)) invalid_label = paddle.gather_nd( input, paddle.nonzero(valid_label >= input.shape[-1])) - if invalid_label.numel() > 0: + if paddle.numel(invalid_label) > 0: raise ValueError( "Target({}) is out of class_dimension's upper bound({})". format(invalid_label[0], input.shape[-1])) -- GitLab