I am trying to generate N sets of independent random numbers. I have a simple code that shows the problem for 3 sets of 10 random numbers. I notice that even though I use th
Adding this answer for reference: The problem of the reproducible result might not come directly from TensorFlow but from the underlying platform. See this issue on Keras
In case of running on an Nvidia GPU, there is a lib from Nvidia that helps to get deterministic results: tensorflow-determinism
pip install tensorflow-determinism
and you use it like this:
import tensorflow as tf
import os
os.environ['TF_DETERMINISTIC_OPS'] = '1'
and it's still recommended to add these fields:
SEED = 123
os.environ['PYTHONHASHSEED']=str(SEED)
random.seed(SEED)
np.random.seed(SEED)
tf.random.set_seed(SEED)
For Tensorflow < 2.1, add above and this:
from tfdeterminism import patch
patch()