Created
April 9, 2020 22:21
-
-
Save gatheluck/c57e2a40e3122028ceaecc3cb0d152ac to your computer and use it in GitHub Desktop.
Set seed for python, numpy and pytorch for reproductiveity.
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
import os | |
import random | |
import numpy as np | |
import torch | |
def set_all_seeds(seed): | |
random.seed(seed) | |
os.environ('PYTHONHASHSEED') = str(seed) | |
np.random.seed(seed) | |
torch.manual_seed(seed) | |
torch.cuda.manual_seed(seed) | |
torch.backends.cudnn.deterministic = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't you mean
os.environ['PYTHONHASHSEED'] = str(seed)
(square brackets) for line 8?