From bdad383c1d7e810e6d43b43c14c123bb7c2f7baa Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Sat, 4 Jul 2020 16:05:02 +0800 Subject: [PATCH] fix test_mobile_net random failed test=develop (#25364) --- .../tests/unittests/dygraph_to_static/test_mobile_net.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py index 49002ed57da..33b5860d7fd 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py @@ -407,12 +407,14 @@ def create_optimizer(args, parameter_list): return optimizer -def fake_data_reader(batch_size, lable_size): +def fake_data_reader(batch_size, label_size): + local_random = np.random.RandomState(SEED) + def reader(): batch_data = [] while True: - img = np.random.random([3, 224, 224]).astype('float32') - label = np.random.randint(0, lable_size, [1]).astype('int64') + img = local_random.random_sample([3, 224, 224]).astype('float32') + label = local_random.randint(0, label_size, [1]).astype('int64') batch_data.append([img, label]) if len(batch_data) == batch_size: yield batch_data -- GitLab