You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This did work: np.random.gamma(shape=2, size=(100, 1)) But it should be more clear in the documentation that this is the limitation on how to use the setting of the seed for numpy via Keras.
Calling this utility is equivalent to the following:
import random
import numpy as np
from keras.utils.module_utils import tensorflow as tf
random.seed(seed)
np.random.seed(seed)
tf.random.set_seed(seed)
Calling np.random.seed(seed) does not affect np.random.default_rng() because by definition default_rng() is standalone and locally-seeded. It does depend on the global seed state. This is well documented by NumPy.
OS: Windows 11
Python == 3.11.0 64 bit
Keras == 3.0.5
keras.utils.set_random_seed() does not set the reproducibility for (at least) Numpy operations.
import numpy as np
import keras
seed = 0
keras.utils.set_random_seed(seed=seed)
random_number_generator = np.random.default_rng()
gamma =
random_number_generator.gamma(shape=2, size=(100, 1))
Multiple runs will produce different random values.
With random_number_generator = np.random.default_rng(seed=seed) multiple runs will produce same random values.
The text was updated successfully, but these errors were encountered: