Skip to content

Instantly share code, notes, and snippets.

@loretoparisi
Created April 8, 2019 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loretoparisi/ae82859c3d4e0d86b1da84674133933a to your computer and use it in GitHub Desktop.
Save loretoparisi/ae82859c3d4e0d86b1da84674133933a to your computer and use it in GitHub Desktop.
Python Randomness - Reproducibility isn't a requirement, it's a necessity!
# Set the seed for hash based operations in python
os.environ['PYTHONHASHSEED'] = '0'
seed=1234
# set the seed for random number generator
rn.seed(seed)
# Set the numpy seed
np.random.seed(seed)
# Set the random seed in tensorflow at graph level
tf.random.set_seed(seed)
@loretoparisi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment