모델은 재현이 가능해야한다.
그래야 내 실험 결과가 거짓이 아니라는 것을 보여줄 수 있고
모델을 최고 성능으로 재사용할 수 있다.
아래의 코드를 통해 모델은 재현이 가능해진다.
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)
'pytorch 사용법' 카테고리의 다른 글
Pytorch로 병렬처리하기 / Multi GPU 사용하기(DataParallel) (0) | 2020.12.09 |
---|---|
pytorch parameter 합치기, loss 합치기 (0) | 2020.10.08 |