From 36fffb7706035dce6f9fcd84c30b961b6c012d47 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 4 May 2020 11:50:53 -0400 Subject: [PATCH] Added example md5 generation Comparison example Added md5 and comparison example for py_transforms Added md5 check for images --- mindspore/dataset/core/configuration.py | 11 ++- .../golden/test_center_crop_01_result.npz | Bin 0 -> 644 bytes tests/ut/python/dataset/test_center_crop.py | 78 ++++++++++++++---- .../dataset/test_random_color_adjust.py | 3 - tests/ut/python/dataset/util.py | 59 ++++++++++++- 5 files changed, 126 insertions(+), 25 deletions(-) create mode 100644 tests/ut/data/dataset/golden/test_center_crop_01_result.npz diff --git a/mindspore/dataset/core/configuration.py b/mindspore/dataset/core/configuration.py index c08f47526e..38b25368b3 100644 --- a/mindspore/dataset/core/configuration.py +++ b/mindspore/dataset/core/configuration.py @@ -16,6 +16,7 @@ The configuration manager. """ import random +import numpy import mindspore._c_dataengine as cde INT32_MAX = 2147483647 @@ -33,10 +34,10 @@ class ConfigurationManager: Set the seed to be used in any random generator. This is used to produce deterministic results. Note: - This set_seed function sets the seed in the python random library function for deterministic - python augmentations using randomness. This set_seed function should be called with every - iterator created to reset the random seed. In our pipeline this does not guarantee - deterministic results with num_parallel_workers > 1. + This set_seed function sets the seed in the python random library and numpy.random library + for deterministic python augmentations using randomness. This set_seed function should + be called with every iterator created to reset the random seed. In our pipeline this + does not guarantee deterministic results with num_parallel_workers > 1. Args: seed(int): seed to be set @@ -54,6 +55,8 @@ class ConfigurationManager: raise ValueError("Seed given is not within the required range") self.config.set_seed(seed) random.seed(seed) + # numpy.random isn't thread safe + numpy.random.seed(seed) def get_seed(self): """ diff --git a/tests/ut/data/dataset/golden/test_center_crop_01_result.npz b/tests/ut/data/dataset/golden/test_center_crop_01_result.npz new file mode 100644 index 0000000000000000000000000000000000000000..2f8b2273df67b4d4ae7db8d3584eab79464b40c6 GIT binary patch literal 644 zcmWIWW@Zs#fB;2?0^OQ-e;64UK$w$3gdwr0DBeIXub`5VK>#cWQV5a+fysWMz5$Vp z3}p<}>M5zk$wlf`3hFif>N*PQY57GZMTvRw`9&$IAYr$}oZ?iVcyUHzK`M~1VW^{E zq^YA&t3W>BYG6*zE6pva)Jx7UO4Z9P%_+$Qx;L?sE50Z-IX|zsq^LBxgsYGNqKYdo z1tMF>=*`et$mGnJRLI<3$P!e@s^QHDgiLLPY*3{sC6xuKT!rirOh9k?TNHA5Gk7z$ z7jgy_a%p%oM}YiaQ^@V-=jZhw2*8B5eMuotQfF)-uSNtbP(Cv^F+H`AFSd|hBZDCW zY^6X3&_2PSLLrcSEUksY84wH7ObSIH7KjEFioq*Gx+5Wz`m$)$VP4u~5FG zPywz-5u`^cs8AWIM+L0MAk%cE&OIx(-HeGRCaux=Tc}!6sFswPT2iQ