From 23a958cdf11951851e68191ac541f46b53349a00 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Mon, 6 Jul 2020 19:19:04 +0800 Subject: [PATCH] fix unittest failed test=develop (#25392) --- .../unittests/dygraph_to_static/test_sentiment.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py index 9d73ff14057..fd5a58be26b 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py @@ -248,13 +248,15 @@ class BiGRU(fluid.dygraph.Layer): def fake_data_reader(class_num, vocab_size, batch_size, padding_size): + local_random = np.random.RandomState(SEED) + def reader(): batch_data = [] while True: - label = np.random.randint(0, class_num) - seq_len = np.random.randint(padding_size // 2, - int(padding_size * 1.2)) - word_ids = np.random.randint(0, vocab_size, [seq_len]).tolist() + label = local_random.randint(0, class_num) + seq_len = local_random.randint(padding_size // 2, + int(padding_size * 1.2)) + word_ids = local_random.randint(0, vocab_size, [seq_len]).tolist() word_ids = word_ids[:padding_size] + [vocab_size] * (padding_size - seq_len) batch_data.append((word_ids, [label], seq_len)) -- GitLab