自剪枝神經網絡
Simple RNN從理論上來看,具有全局記憶能力,因為T時刻,遞歸隱層一定記錄着時序為1的狀態
但由於Gradient Vanish問題,T時刻向前反向傳播的Gradient在T-10時刻可能就衰減為0。
從Long-Term退化至Short-Term。
盡管ReLU能夠在前饋網絡中有效緩解Gradient Vanish,但RNN的深度過深,替換激活函數治標不治本。
$\left | \prod_{j=p+1}^{t}\frac{\partial b_{h}^{j}}{\partial b_{h}^{j-1}}\right |\leqslant (\beta_{W}\cdot\beta_{h})^{t-p} \quad where \quad \beta =UpperBound$
上式中指明的根源所在,由於W和h兩個矩陣多次冪導致受數值影響敏感,簡而言之就是深度過大。
大部分Long-Term情況下,不需要提供路徑上完整的信息,但反向傳播還是循規蹈矩地穿過這些冗深度。
解決方案之一是,設置可自主學習的參數來屏蔽掉這些無用的信息,與"降維"相似,這種方法叫"降層"
神經網絡的剪枝策略很簡單,就是添加參數矩陣,經過一定周期的學習,選擇性屏蔽掉輸入,精簡網絡。
從結構上來看,類似“樹套樹”,就是”神經網絡套神經網絡“。
動態門結構
簡單概括:
★LSTM將RNN的輸入層、隱層移入Memory Cell加以保護
★Input Gate、Forget Gate、Output Gate,通過訓練參數,將Gate或開(置1)或閉(置0),保護Cell。
在時序展開圖上則更加清晰:
公式定義
原版LSTM最早在[Hochreiter&Schmidhuber 97]提出。
今天看到的LSTM是[Gers 2002]改良過的 extended LSTM。
extended LSTM擴展內容:
★Forget Gate,用於屏蔽t-1以及之前時序信息。
在時序展開圖上,由左側鎖住以保護Cell。
★三態門控:
97年提出的Gate輸入類似RNN,分為兩態Weight矩陣:
☻Wx——序列輸入信息
☻Wh——遞歸隱態輸入信息
2002年補充了第三態:
☻Wc——遞歸Cell態輸入信息
將Cell的時序狀態引入Gate,稱為Peephole Weights。
唯一作用似乎是提升LSTM精度,Alex Graves的博士論文中這么說:
The peephole connections,meanwhile, improved the LSTM’s ability to learn tasks that require precise
timing and counting of the internal states.
具體實現的時候,為了增加計算效率,可以忽視:
Theano的Tutorial中這么說道:
The model we used in this tutorial is a variation of the standard LSTM model.
In this variant, the activation of a cell’s output gate does not depend on the memory cell’s state .
This allows us to perform part of the computation more efficiently (see the implementation note, below, for details).
而CS224D Lecture8中壓根就沒提。
所以雙態Gate可能是更為主流的LSTM變種。
2.1 前向傳播
輸入門:
$i_{t}=Sigmoid(W_{i}x_{t}+U_{i}h_{t-1}+V_{i}C_{t-1})$ ①
遺忘門:
$f_{t}=Sigmoid(W_{f}x_{t}+U_{f}h_{t-1}+V_{f}C_{t-1})$ ②
輸出門:
$O_{t}=Sigmoid(W_{o}x_{t}+U_{o}h_{t-1}+V_{o}C_{t})$ ③
原始Cell(RNN部分):
$\tilde{C_{t}}=Tanh(W_{c}x_{t}+U_{c}h_{t-1})$ ④
門套Cell:
$C_{t}=i_{t}\cdot\tilde{C_{t}}+f_{t}\cdot C_{t-1}$ (輸入門+遺忘門) ⑤
$h_{t}=O_{t}\cdot Tanh(C_{t}) \quad where \quad h_{t}=FinalOutput$ (輸出門) ⑥
————————————————————————————————————————————————————
仔細觀察①②③④,發現除了Peephole Weights引入的$V$陣,這四個式子是一樣的。
Theano中為了GPU能夠一步並行計算,沒有使用Peephole Weights,這樣①②③④就是一個基本並行模型:
以相同的代碼,運算數據集在空間中的不同部分。