From c357d935937d37e086e59b41ba54b79234de46e5 Mon Sep 17 00:00:00 2001 From: wj-Mcat <1435130236@qq.com> Date: Sun, 9 Oct 2022 11:13:20 +0000 Subject: [PATCH 1/2] fix bert unittest bug --- tests/transformers/bert/test_modeling.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/transformers/bert/test_modeling.py b/tests/transformers/bert/test_modeling.py index 81ef6ded0f2d..811294fd4519 100644 --- a/tests/transformers/bert/test_modeling.py +++ b/tests/transformers/bert/test_modeling.py @@ -312,12 +312,10 @@ def create_and_check_for_question_answering( return_dict=self.return_dict) if token_labels is not None: result = result[1:] - elif paddle.is_tensor(result): - result = [result] - self.parent.assertEqual(result[1].shape, + self.parent.assertEqual(result[0].shape, [self.batch_size, self.seq_length]) - self.parent.assertEqual(result[2].shape, + self.parent.assertEqual(result[1].shape, [self.batch_size, self.seq_length]) def create_and_check_for_sequence_classification( From 0890eca90bcdf8533aa41607669d33cd39815733 Mon Sep 17 00:00:00 2001 From: wj-Mcat <1435130236@qq.com> Date: Sun, 9 Oct 2022 11:42:36 +0000 Subject: [PATCH 2/2] change token_labels -> sequence_labels --- tests/transformers/bert/test_modeling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/transformers/bert/test_modeling.py b/tests/transformers/bert/test_modeling.py index 811294fd4519..cf1f3baf1325 100644 --- a/tests/transformers/bert/test_modeling.py +++ b/tests/transformers/bert/test_modeling.py @@ -310,7 +310,7 @@ def create_and_check_for_question_answering( start_positions=sequence_labels, end_positions=sequence_labels, return_dict=self.return_dict) - if token_labels is not None: + if sequence_labels is not None: result = result[1:] self.parent.assertEqual(result[0].shape,