深度學習的一些知識點總結

目標函數要能防止網絡的輸出始終是一個單一數值,例如0。

  1. 當training set和test set數據分佈不一致時,保證validate set和test set數據分佈一致
  2. High bias? 增大加深網絡。Large and deep。
  3. High variance?找更多訓練數據,regularization

增大加深網絡,同時增大訓練集數據量,總是可取的。

  1. Regularization:
    • L2 平方和, 對矩陣是Frobenius Norm,在神經網絡中也被稱作 Weight decay
    • L1 絕對值的和
    • Dropout
      • 訓練的時候在每一層按照閾值p(0<p<1)p (0<p<1)隨機忽略一些節點,每一層的輸出aa最後要除以pp,即a=a/pa = a/p,以保持輸出的大小。By doing this you are assuring that the result of the cost will still have the same expected value as without drop-out. (This technique is also called inverted dropout.)
      • 對於參數較多的層,設置較大的dropout率,參數較少的層,減小dropout率。
      • 對輸入層不要dropout
      • 測試時關閉dropout,只在訓練時使用。
      • Apply dropout both during forward and backward propagation.
      • The dropped neurons don’t contribute to the training in both the forward and backward propagations of the iteration.
      • At each iteration, you train a different model that uses only a subset of your neurons. With dropout, your neurons thus become less sensitive to the activation of one other specific neuron, because that other neuron might be shut down at any time.
    • 數據擴增,增大數據量。水平翻轉、旋轉、變形
    • Early stopping。驗證集誤差開始增加時停止訓練。此時權重參數還比較小,因此能避免overfitting
    • Note that regularization hurts training set performance! This is because it limits the ability of the network to overfit to the training set. But since it ultimately gives better test accuracy, it is helping your system.

爲什麼Regularization可以減弱過擬合?
:1. 設置一個較大的λ\lambda參數,可以使得參數ww很接近0,導致網絡中很多節點都失效了,變相地把網絡減小、變淺了。
2. 對於sigmoid和tanh等激活函數而言,zz值較小時處於線性區,較大時處於非線性區。添加regularization之後,使得參數ww的值變小,zz的值也變小,將一層網絡的輸出拉入到了線性區。這樣,每層網絡近似是線性的,那麼多層網絡也近似是線性的,減少了過擬合。

爲什麼dropout有regularization的作用?
:如下圖,對於網絡中的某一個節點而言,它的輸入節點都有可能被關掉(隨機的),因此該節點無法依賴任何一個輸入節點,只能把權值分配給所有的節點,這變相地使得參數ww變小了。
在這裏插入圖片描述

  1. Normalizing訓練集,根據均值和方差,歸一化。
    • 歸一化後Cost function的切面接近於一個圓,梯度下降更快。可以加速訓練過程。
      在這裏插入圖片描述
  2. 參數初始化
    • w = np.random.randn(shape) * np.sqrt(1/n), 使參數的方差是1n[l]\sqrt{\dfrac{1}{n^{[l]}}}
    • 使用ReLU激活函數時,會初始化參數方差爲2n[l1]\sqrt{\dfrac{2}{n^{[l-1]}}},其中n[l1]n^{[l-1]}是上一層的節點數量,也被稱作He initialization
    • tanh激活函數,方差取1n[l1]\sqrt{\dfrac{1}{n^{[l-1]}}}
    • Xavier初始化,方差取2n[l1]n[l]\sqrt{\dfrac{2}{n^{[l-1]}\cdot n^{[l]}}}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章