- Overfitting이 의심될 때 가장 먼저 시도할 것
1. L2&L1 regularization
-
L2 regularization
w:(n[l−1],n[l])J(w[1],...,w[L])=m1i=1∑mL(y^(i),y(i))+2mλl=1∑L∥w[l]∥F2∥w[l]∥F2=i=1∑n[l−1]j=1∑n[l](wij[l])2
-
L1 regularization
J(w[1],...,w[L])=m1i=1∑mL(y^(i),y(i))+2mλl=1∑L∥w[l]∥1∥w[l]∥1=i=1∑n[l−1]j=1∑n[l]∣∣∣∣wij[l]∣∣∣∣
w will be sparse, which means there are many 0s in the w vector. Some people say this can help with compressing the model. Because the certain parameters are 0, then we need less memory to store the model. But Andrew Ng doesn't think this helps much at all.
-
λ: hyperparameter, 각 층마다 다른 값을 적용해도 된다.
2. Backpropagation (Why Weight decay?)
3. Regularization이 Overfitting을 해결할 수 있는 이유
![](https://velog.velcdn.com/images/zzwon1212/post/dc37c6c1-97b1-403f-97c5-c516bf1942cb/image.png)
activation function이 tanh일 때를 살펴보자. λ가 커지면 W[l]은 작아지기 때문에 z[l]도 작아진다. 작은 z값은 tanh에서 선형적인 부분만을 사용한다. 따라서 신경망은 복잡한 비선형적인 구조보다는 비교적 간단한 선형적인 구조를 가지게 된다.
4. 기타 regularization 방법
5. PyTorch 적용
torch.optim.SGD()
의 weight_decay
를 설정
📙 참고