Skip to content

Instantly share code, notes, and snippets.

@yang-zhang
Last active January 20, 2020 14:44
Embed
What would you like to do?
set_seed function to lock pytorch randomness for reproducibility.
def set_seed(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