I need to reproduce results with AutoKeras for the same input and configurations: I tried the following at the beginning of my notebook but still didn't got the same results.
I am using Tensorflow 2.0.4 and AutoKeras 1.0.12
seed_value= 0
import os
os.environ['PYTHONHASHSEED']=str(seed_value)
os.environ['TF_CUDNN_DETERMINISTIC'] = str(seed_value)
import tensorflow as tf
tf.random.set_seed(seed_value)
from keras import backend as K
import autokeras as ak
import random
random.seed(seed_value)
import numpy as np
np.random.seed(seed_value)
Note: I want to reproduce results at different times; i.e. to get the same result after closing the notebook, and run the code again .. not during the same session.
I guess, you need to seed the generators before each call you want to be reproducable. The best option is to make such a decorator (or a context manager):
import contextlib
@contextlib.contextmanager
def reproducable(seed_value=0):
import os
os.environ['PYTHONHASHSEED']=str(seed_value)
os.environ['TF_CUDNN_DETERMINISTIC'] = str(seed_value)
import tensorflow as tf
tf.random.set_seed(seed_value)
from keras import backend as K
import autokeras as ak
import random
random.seed(seed_value)
import numpy as np
np.random.seed(seed_value)
yield
@reproducable()
def main():
# ...put your code here...
UPD
Note: I want to reproduce results at different times; i.e. to get the same result after closing the notebook, and run the code again .. not during the same session.
and?