From d1fd3691581925ed4dcd850b8ed0d6beff3242b9 Mon Sep 17 00:00:00 2001 From: yancong <32220263+ice-tong@users.noreply.github.com> Date: Fri, 28 Jan 2022 14:17:25 +0800 Subject: [PATCH] fix(NumpyArrayIterator): for determistic results Add the missng ssed argument to `self.image_data_generator.get_random_transform` for determistic results. Especially during mutli-thread, we cannot set numpy.rand.seed out of the thread, this arugment pass is important! --- keras_preprocessing/image/numpy_array_iterator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keras_preprocessing/image/numpy_array_iterator.py b/keras_preprocessing/image/numpy_array_iterator.py index f90aaec8..b8cf8d8e 100644 --- a/keras_preprocessing/image/numpy_array_iterator.py +++ b/keras_preprocessing/image/numpy_array_iterator.py @@ -158,7 +158,7 @@ def _get_batches_of_transformed_samples(self, index_array): dtype=self.dtype) for i, j in enumerate(index_array): x = self.x[j] - params = self.image_data_generator.get_random_transform(x.shape) + params = self.image_data_generator.get_random_transform(x.shape, seed=self.seed) x = self.image_data_generator.apply_transform( x.astype(self.dtype), params) x = self.image_data_generator.standardize(x)