Remove old repro files
[notebooks.git] / fmda / reproducibility.py
blob02a0022b1c136606b78e6ee15bdbf1f5c9c13ea0
1 # make session reproducible
2 import os
3 import random
4 import numpy as np
5 import tensorflow as tf
6 environ={'TF_DETERMINISTIC_OPS':'1','PYTHONHASHSEED':'0','TF_CPP_MIN_LOG_LEVEL':'2'}
7 # print('setting',environ)
8 os.environ.update(environ)
9 def set_seed(seed=123):
10 random.seed(seed)
11 np.random.seed(seed)
12 os.environ['PYTHONHASHSEED'] = str(seed)
13 tf.random.set_seed(seed)
14 tf.keras.utils.set_random_seed(seed)
15 tf.config.experimental.enable_op_determinism()
16 print('resetting random seeds to %i' % seed)
17 # set_seed()
18 # print('call set_seed() or set_seed(seed=value) to reset')