From 6cd96c19f52f389195e81de71b301a1c274a2664 Mon Sep 17 00:00:00 2001 From: root <12272008@bjtu.edu.cn> Date: Tue, 27 Apr 2021 06:04:43 +0000 Subject: [PATCH] fix ci coverage --- .../fluid/tests/unittests/test_cross_entropy_loss.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/test_cross_entropy_loss.py b/python/paddle/fluid/tests/unittests/test_cross_entropy_loss.py index b30a5227a9a..6a037ad6be7 100644 --- a/python/paddle/fluid/tests/unittests/test_cross_entropy_loss.py +++ b/python/paddle/fluid/tests/unittests/test_cross_entropy_loss.py @@ -1377,6 +1377,15 @@ class TestCrossEntropyFAPIError(unittest.TestCase): self.assertRaises(ValueError, test_LabelValue) + def test_LabelValueNeg(): + input_data = paddle.rand(shape=[20, 100]) + label_data = paddle.randint(0, 100, shape=[5, 1], dtype="int64") + label_data[0] = -1 + paddle.nn.functional.cross_entropy( + input=input_data, label=label_data) + + self.assertRaises(ValueError, test_LabelValueNeg) + if __name__ == "__main__": unittest.main() -- GitLab