본문 바로가기
Study/Data Science

딥러닝 기초 - Underfitting, Overfitting

by SeulKom 2022. 3. 21.

DNN (Deep Neural Network) 란?

Neural Network에서 hidden layer가 2개 이상인 경우 (hidden layer가 점점 많아지면)를 DNN이라 함.

사람의 뇌를 닮아서 사람이 할 수 있는걸 전부 할 수 있는 것 같지만 아래와 같은 문제점이 존재.

  • Underfitting : 학습 부족
  • Slow : 느림
  • Overfitting : 과하게 학습하여 융통성이 없음 

모델 복잡도에 따른 Underfitting과 Overfitting

 

1. Underfitting 해결 방법

Back propagation (오차 역전파)

내가 틀린 정도를 '미분(기울기)' 한 거를 앞 단으로 다시 전달하여 업데이트

  • Vanish gradient (그래디언트 소실) 현상 발생 

  • activation 함수로 sigmoid 를 많이 사용하는데, 미분 기울기가 없는 곳을 참조하는 경우 업데이트 정보가 사라져 감 
    • 반대 현상도 존재 - 미분 기울기 있는 것만 참조하여 기하급수적으로 가중치 증가 (Exploding gradient, 그래디언트 폭주)

sigmoid 함수

  • 다른 activation 함수를 사용하여 해결 - ReLU (Rectified Linear Units)

 

 

2. Overfitting (과적합) 해결 방법

DropOut

학습 시킬 때, 일부러 정보를 누락 시키거나 중간 중간 노드를 제외

다양한 상황을 제공함으로써 중요 paramter를 학습할 수 있도록 도와주는 역할을 함

 

Regularization

reuglarizer(function의 복잡도를 줄이기 위해 페널티를 부과)를 사용하여 중요한 input에 focus하는 방법

 

L1 페널티 (Lasso)

페널티의 가중치를 0으로 줄이는 것

중요도가 적은 가중치를 0으로 변경하면서 변수 선택을 함 (Lasso regression과 동일)

  • 고차원 데이터를 사용하더라도 필요한 변수만 선택해서 모델의 복잡도가 감소
  • 마름모꼴로 나타나기 때문에, 학습 시 미분이 안되는 지점이 존재하여 Ridge보다 학습이 어려움

L2 페널티 (Ridge)

제곱된 가중치들을 기반으로 중요한 변수에 더 큰 가중치를 제공하고, 반대로 중요하지 않으면 극도로 작은 가중치를 갖게 되어 변수를 선택

 

ElasticNet 

  • L1 (Lasso) + L2 (Ridge) 동시 제약

Lasso (L1 Norm), Ridge (L2 Norm), ElasticNet(L1 + L2 Norm)

References 

https://machinelearning101.readthedocs.io/en/latest/_pages/07_model_performance.html

 

7. Model Performance — Machine Learning 101 documentation

When training ML Models, it is important to avoid overfitting the training data. Overfitting occurs when the ML model learns the noise in the training data and thus does not generalize well to data it has not been trained on. One hyperparameter that affect

machinelearning101.readthedocs.io

https://towardsdatascience.com/from-linear-regression-to-ridge-regression-the-lasso-and-the-elastic-net-4eaecaf5f7e6

 

From Linear Regression to Ridge Regression, the Lasso, and the Elastic Net

And why you should learn alternative regression techniques.

towardsdatascience.com