boostcampaitech5 / level1_imageclassification-cv-07

level1_imageclassification-cv-07 created by GitHub Classroom
1 stars 1 forks source link

[Update] early stopping #3

Closed kjs2109 closed 1 year ago

kjs2109 commented 1 year ago

loss가 특정 횟수 이상 연속으로 증가하면 학습이 자동으로 종료되는 early stopping 기능을 구현했습니다. 특정 횟수 n은 커멘드 라인 명령으로 설정할 수 있게 하였고 default=0은 early stopping 기능을 사용하지 않는 것으로 구현하였습니다. python train.py --early_stopping n 과 같은 방식으로 사용할 수 있습니다. pytorchtools.py 파일을 command 폴더 안에 넣고 싶었는데, from command.pytorchtools import EarlyStopping을 하니 계속 pytorchtools 파일을 못 찾는 문제가 발생해서 일단은 cv-07_image-classification 폴더 아래에 넣었습니다. 그냥 이대로 사용해도 될지 아니면 command 폴더 안에 넣는게 좋을지 의견 주시면 감사하겠습니다!

nstalways commented 1 year ago

command 폴더 안에 넣는 게 깔끔하겠다는 생각이 들긴 하네요. 혹시 주성님 환경에서 train.py는 루트 디렉토리 바로 아래에 있을까요?

nstalways commented 1 year ago

command 폴더 안에 넣는 게 깔끔하겠다는 생각이 들긴 하네요. 혹시 주성님 환경에서 train.py는 루트 디렉토리 바로 아래에 있을까요?

방금 테스트해보았는데 제 경우에는 import error가 발생하지 않네요. 구조는 다음과 같습니다.

cv-07_image-classification(root)
-> command
--> pytorchtools.py
- test.py
# test.py
from command.pytorchtools import EarlyStopping

a = EarlyStopping()
print(a)
97DongHyeokOH commented 1 year ago

저도 command 폴더 아래 넣는 게 더 깔끔하다고 생각합니다.

kjs2109 commented 1 year ago

밑에 물결 표시가 있어서 에러인 줄 알았는데 정상적으로 작동 되네요..!! 피드백 감사합니다ㅎㅎ 추가적으로 .gitignore 파일 추가했습니다.

codehyunn commented 1 year ago

확인했습니다. Merge해도 좋을 것 같네요 :)