Skip to content

Instantly share code, notes, and snippets.

@cccntu
Last active May 21, 2020 05:54
Show Gist options
  • Save cccntu/efd1ef91e6df1ebd05d530fa8995aff3 to your computer and use it in GitHub Desktop.
Save cccntu/efd1ef91e6df1ebd05d530fa8995aff3 to your computer and use it in GitHub Desktop.
make pytroch code reproducible
import random
import numpy as np
import torch
def set_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(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