OOP + 모듈 -> 프로젝트
실행, 데이터, 모델, 설정, 로깅, 지표, 유틸리티 등 다양한 모듈들을 분리하여 프로젝트 템플릿화 할 수 있다.
PyTorch Template 추천
https://github.com/victoresque/pytorch-template
터미널 실행 예시
conda activate torch
python new_project.py MyProject
cd MyProject
code .
python train.py -c config.json
train.py
if __name__ == '__main__':
# 실행 창에서 argument 지정해줄 때,
args = argparse.ArgumentParser(description='PyTorch Template')
# 실행할 때 설정 파일 불러오기. 예시: python train.py -c config.json
args.add_argument('-c', '--config', default=None, type=str,
help='config file path (default: None)')
# 예전에 실행했던 것을 연속해서 실행할 것인지
args.add_argument('-r', '--resume', default=None, type=str,
help='path to latest checkpoint (default: None)')
# cpu or gpu
args.add_argument('-d', '--device', default=None, type=str,
help='indices of GPUs to enable (default: all)')
등등...
다음주 프로젝트부터 다시 실전에서 부딪혀보자... ㅎㅎ...