Skip to content

Instantly share code, notes, and snippets.

@ahmedbesbes
Created October 19, 2021 10:18
Show Gist options
  • Save ahmedbesbes/b767f9b7592715d716df85b3d47b8a6b to your computer and use it in GitHub Desktop.
Save ahmedbesbes/b767f9b7592715d716df85b3d47b8a6b to your computer and use it in GitHub Desktop.
def seed_everything(seed=1234):
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
tensorflow.random.set_seed(seed)
tensorflow.keras.layers.Dropout(x, seed=SEED)
tensorflow.image.random_flip_left_right(x, seed=seed)
tensorflow.random_normal_initializer(x, y, seed=seed)
# call this function a the beginning of your script
seed_everything()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment