diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index e59ef5ebfb0ab26c16c78933733bc11c0c4148d0..e6efde836284ac361f9781a0cb18b0df72afe354 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1667,11 +1667,11 @@ def cross_entropy(input, label_min = paddle.min(valid_label) label_max = paddle.max(valid_label) if label_min < 0: - raise ValueError("label should not out of bound, but got{}". - format(label_min)) + raise ValueError("Target {} is out of lower bound.".format( + label_min.item())) if label_max >= input.shape[axis]: - raise ValueError("label should not out of bound, but got{}". - format(label_max)) + raise ValueError("Target {} is out of upper bound.".format( + label_max.item())) if core.is_compiled_with_npu() or core.is_compiled_with_mlu(): _, _, out = _C_ops.softmax_with_cross_entropy( input, label, 'soft_label', soft_label, 'ignore_index',