Skip to content

Instantly share code, notes, and snippets.

@xu-ji
Last active December 10, 2021 19:00
Show Gist options
  • Save xu-ji/e34182a00c20180ec233d16c1b430145 to your computer and use it in GitHub Desktop.
Save xu-ji/e34182a00c20180ec233d16c1b430145 to your computer and use it in GitHub Desktop.
Setting seeds
# run before you do anything else in the code, for each experiment
def set_seed(seed):
random.seed(0)
np.random.seed(0)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment