๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
TIL/Coursera(Google ML Bootcamp)

[Improving Deep Neural Networks] Practical Aspects of Deep Learning :: seoftware

by seowit 2021. 8. 25.

 

๐Ÿ“œ ๊ฐ•์˜ ์ •๋ฆฌ 

 

* Cousera ๊ฐ•์˜ ์ค‘ Andrew Ng ๊ต์ˆ˜๋‹˜์˜ Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and Optimization ๊ฐ•์˜๋ฅผ ๊ณต๋ถ€ํ•˜๊ณ  ์ •๋ฆฌํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

* ์˜์–ด ๊ณต๋ถ€๋ฅผ ํ•˜๋ ค๊ณ  ๋ถ€๋ถ„์ ์œผ๋กœ ์˜์–ด๋กœ ๊ฐ•์˜๋ฅผ ์ •๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ˜น์‹œ ํ‹€๋ฆฐ ๋ถ€๋ถ„์ด๋‚˜ ์–ด์ƒ‰ํ•œ ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€๋กœ ์•Œ๋ ค์ฃผ์‹œ๊ฑฐ๋‚˜ ๋„˜์–ด๊ฐ€์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค


Setting Up your Machine Learning Application

1. Train/dev/test

  • ratio of each part 
    • (Small dataset) Trainng : Validation : Testing = 60 : 20 : 20
    • (Large dataset) Training : Validation : Testing = 98 : 1 : 1 or 95 : 2.5 : 2.5

 

Regularizing your Neural Network

1. Regularization

There is two ways to prevent high variance problems. One of the first thing is to try regularization and the other thing is to get more trainig datas. 

  • How regularization work?
    • Regularization term is added to loss function. There are L1 regularization and L2 regularizaton, L2 regularization is just used much much much more often.
    • L2 regularization is also called "Frobenius norm". It means the sum of square of elements of a matrix
  • Neural Network
    • λ/m*w_l is added to dw_l. It is derivative of l2-regularization.

2. Why Regularization Reduces Overfitting?

The regularization term(purple part) pernalize the weight matrices from being too large.

For example, let's suppose we use a tanh function as an activation function.W value is close to zero if lambda is big number because the cost function J should be close to zero. Tanh function has linear slope in the scope near zero, but it has smooth slope away from the zero.๋น„์šฉํ•จ์ˆ˜๋Š” ๊ฐ’์ด ์ž‘์•„์ ธ์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋žŒ๋‹ค๋ฅผ ํฐ ์ˆ˜๋กœ ํ•˜๋ฉด W๋Š” 0์— ๊ฐ€๊นŒ์›Œ์ ธ์•ผ ํ•œ๋‹ค. z = wx+b ์—์„œ w๊ฐ€ 0์— ๊ฐ€๊นŒ์›Œ์ง€๋ฉด z๋„ 0์— ๊ฐ€๊นŒ์›Œ์ง€๊ฒŒ ๋œ๋‹ค. z๋Š” tanh(ํ™œ์„ฑํ•จ์ˆ˜)์˜ input์ด ๋˜๋Š”๋ฐ, tanh์˜ ๊ฒฝ์šฐ 0 ์ฃผ๋ณ€์˜ ๊ธฐ์šธ๊ธฐ๋Š” linear function์— ๊ฐ€๊นŒ์›Œ์„œ ์ƒ๋Œ€์ ์œผ๋กœ ์ „์ฒด์ ์ธ ํ•จ์ˆ˜๊ฐ€ linearํ•˜๊ฒŒ ๋˜๋ฉฐ ์‹ฌํ”Œํ•ด์ง€๋Š” ํšจ๊ณผ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

์—ฌ๊ธฐ์„œ ๊ถ๊ธˆํ•œ ์ ์€ tanh๊ฐ€ ์•„๋‹ˆ๋ฉด regularizationn ํšจ๊ณผ๊ฐ€ ์žˆ๋‚˜? ์ด๋Ÿฐ ์ƒ๊ฐ์ด ๋“ ๋‹ค. ReLU์—๋„ ์ ์šฉ์ด ๋˜๋Š”๊ฑด๊ฐ€? 

3. Dropout Regularization

Dropout is to set some probability(here 0.5) of eliminating a node in neural network. We are going to keeping or removing each node with a probability of 0.5.

4. Understanding Dropout

Why does dropout work?

Intuition : Can’t rely on any one feature, so have to spread out weights. Shrink weights

Notice that you should set different keep.probs for different layers, you should avoid to use dropout at the input layer and the classifier layer(=keep probability with 1.0).

In computer vision, the input sizes is so big in putting all these pixels that you almost never have enough data. And so dropout is very frequently used by the computer vision and there are some common vision research that dropout is pretty much always used as a default.

 

5. Other Regularization Methods

  • Data augmentatio
  • Early stopping

 

Setting Up your Optimization Problem

1. Normalizing Inputs

 

2. Vanishing/Exploding Gradients

 

3. Weight Initialization for Deep Networks

The way you initialize weight depends on activation function.

4. Numerical Aprroximations of Gradients

 

๋Œ“๊ธ€