AI/pytorch

    copy.deepcopy(model.state_dict())

    https://tutorials.pytorch.kr/beginner/saving_loading_models.html#id5v 모델 저장하기 & 불러오기 Author: Matthew Inkawhich, 번역: 박정환,. 이 문서에서는 PyTorch 모델을 저장하고 불러오는 다양한 방법을 제공합니다. 이 문서 전체를 다 읽는 것도 좋은 방법이지만, 필요한 사용 예의 코드만 참고하 tutorials.pytorch.kr 참고 파이토치 공식문서 early stopping에서 저장한 가중치를 복사해올때 best_model_wts = copy.deepcopy(model.state_dict()) copy.deepcopy(model.state_dict()) NOTE 만약 (검증 손실(validation loss) 결과에..

    파이토치 환경에서 randomness를 고정하기 위한 방법

    https://tootouch.github.io/experiment/reproduction_pytorch/ https://hoya012.github.io/blog/reproducible_pytorch/ 자세한 설명은 다른 분들이 적어둔 걸 참고 하고 시간이 없는 나는 일단 적어두고 복붙 def seed_everything(seed=1): """ Seed and GPU setting """ random.seed(seed) os.environ['PYTHONHASHSEED'] = str(seed) np.random.seed(seed) torch.manual_seed(seed) torch.cuda.manual_seed(seed) torch.backends.cudnn.deterministic = True # to..