[Pytorch] How to Control Randomization in Pytorch
2021. 3. 9. 10:48ㆍ카테고리 없음
# set random seed
random_seed = 999
# for pytorch
torch.manual_seed(random_seed)
torch.cuda.manual_seed(random_seed)
torch.cuda.manual_seed_all(random_seed) # for multi-GPU
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
# for numpy and random
np.random.seed(random_seed)
random.seed(random_seed)