pytorch 사용법
pytorch 모델 재현 가능하도록 만들기
jjwdl
2020. 11. 20. 21:04
모델은 재현이 가능해야한다.
그래야 내 실험 결과가 거짓이 아니라는 것을 보여줄 수 있고
모델을 최고 성능으로 재사용할 수 있다.
아래의 코드를 통해 모델은 재현이 가능해진다.
torch.manual_seed(random_seed)
torch.cuda.manual_seed(random_seed)
torch.cuda.manual_seed_all(random_seed) # if use multi-GPU
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
np.random.seed(random_seed)
random.seed(random_seed)