https://thenerdstation.medium.com/how-to-unit-test-machine-learning-code-57cf6fd81765#9c53

 

How to unit test machine learning code.

Edit: The popularity of this post has inspired me to write a machine learning test library. Go check it out!

thenerdstation.medium.com

Machine learning model unit testing에 관한 이 글에서 소개된 reddit post에서, model output이 하나인데 softmax CrossEntropy를 쓰고 있다.

값 하나를 softmax에 넣어주면 항상 1로 normalize되므로, CrossEntropyLoss가 항상 1이 돼서 학습이 안되는 문제.

 

현재 하는 분석 (ex. regression vs classification), 데이터의 종류에 따라 (ex. n-way classification) 어떤 loss를 쓰느냐가 학습 여부를 결정한다!

각 loss가 어떤 역할을 하는지, 언제 왜 쓰이는지 개념을 알아야 제대로 활용할 수 있음.

 

흔히 supervised learning에서는 MSE (regression), CrossEntropy (classification) 를 씀

 

Regression / Classification 별로 어떤 loss가 있는지 설명해줌 (코드는 볼 필요 없고, 종류만 보기)

https://machinelearningmastery.com/how-to-choose-loss-functions-when-training-deep-learning-neural-networks/

 

* Pytorch에서 CrossEntropyLoss는 softmax를 포함하기 때문에, 모델 맨 마지막에 softmax layer 추가할 필요 X

Binary classification의 경우에, BCEWithLogitsLoss도 비슷하게 sigmoid를 포함하고 있음.

https://nuguziii.github.io/dev/dev-002/

'<기타 공부> > [기계 학습]' 카테고리의 다른 글

Train / Test / Validation dataset  (0) 2022.04.06
Bias-Variance tradeoff  (0) 2021.08.02
Dropout  (0) 2021.06.21
[Pytorch] Optimizer 종류 간략 설명  (0) 2021.06.10
AutoML - 하이퍼 파라미터 Training  (0) 2021.05.18

+ Recent posts