Last active
April 20, 2020 20:35
-
-
Save wasdee/87a6dc0b8884affb2a546ca6036cad04 to your computer and use it in GitHub Desktop.
[Reproducibility In Data Science] #Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cite: https://www.youtube.com/watch?v=Ys8ofBeR2kA | |
# Run python or jupyter with | |
# $ PYTHONHASHSEED=0 jupyter notebook | |
# $ PYTHONHASHSEED=0 python code.py | |
# check | |
if os.environ.get("PYTHONHASHSEED") != "0": | |
raise Exception("You must set PYTHONHASHSEED=0 when starting the Jupyter server to get reproducible results.") | |
import random | |
random.seed(42) | |
import numpy as np | |
np.random.seed(42) | |
import tensorflow as tf | |
tf.set_random_seed(42) | |
# check for other library as well |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! Thanks a lot!