Skip to content

Instantly share code, notes, and snippets.

@halecakir
Forked from wasdee/aNote.py
Created April 20, 2020 20:35
Show Gist options
  • Save halecakir/3aee95cd1515afa3362ca2b65d656dd6 to your computer and use it in GitHub Desktop.
Save halecakir/3aee95cd1515afa3362ca2b65d656dd6 to your computer and use it in GitHub Desktop.
[Reproducibility In Data Science] #Python
# 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