1 # make session reproducible
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):
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
)
18 # print('call set_seed() or set_seed(seed=value) to reset')