iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 28
1
AI & Data

機器學習模型圖書館:從傳統模型到深度學習系列 第 29

29 Autoregressive generative model

在前面的 Transformer 的文章中有提到了 auto-regressive 的特質。

When Recurrent Models Don't Need to be Recurrent 這篇文章以及他的論文當中又在重述了這件事。

他們探討了是不是所有 recurrent 模型都可以被換成 auto-regressive 的模型呢?

答案幾乎是肯定的。為什麼說幾乎是肯定的呢?因為他需要滿足一些條件,才能達成訓練上模型的穩定性要求。

Stable recurrent models

問題描述是這樣的:

理論上來說,一個有 好行為(well-behaved) 的 recurrent neural network 是否總是可以被差不多大小的 feed-forward network 取代,在不損失效能的情況下?

這時候我們就需要知道什麼樣的 RNN 是有好行為(well-behaved)的?

當然你可以設計一個非線性的 RNN 讓 feed-forward network 無法取代,只要讓他無法用 gradient descent 訓練起來就可以了。

也就是說,好行為 的 RNN 就是,有辦法用 gradient descent 訓練起來,而不會讓梯度爆炸或是消失的模型。這樣穩定(stable)的模型就有辦法用 feed-forward network 去逼近。

論文中證明了一個重要的定理(論文中有正式的版本),我先寫他的原始描述,然後解釋:

Thm.

Assume the system https://chart.googleapis.com/chart?cht=tx&chl=%5Cphi is https://chart.googleapis.com/chart?cht=tx&chl=%5Clambda-contractive. Under additional smoothness and Lipschitz assumptions on the system https://chart.googleapis.com/chart?cht=tx&chl=%5Cphi, the prediction function https://chart.googleapis.com/chart?cht=tx&chl=f, and the loss https://chart.googleapis.com/chart?cht=tx&chl=p, if

https://chart.googleapis.com/chart?cht=tx&chl=k%20%5Cge%20O(log(N%5E%7B1%2F(1-%5Clambda)%5E3%7D%20%2F%20(%5Cepsilon%20(1-%5Clambda)%5E2)))

then after N steps of projected gradient descent with decaying step size https://chart.googleapis.com/chart?cht=tx&chl=%5Calpha_t%20%3D%20O(1%2Ft), https://chart.googleapis.com/chart?cht=tx&chl=%7C%7Cw_%7Brecurr%7D%20-%20w_%7Btrunc%7D%7C%7C%20%5Cle%20%5Cepsilon, which in turn implies https://chart.googleapis.com/chart?cht=tx&chl=%7C%7Cy_t(w_%7Brecurr%7D)%20-%20y_t%5Ek(w_%7Btrunc%7D)%7C%7C%20%5Cle%20O(%5Cepsilon).

當你把以上定理認真看完之後你就會昏了。基本上是說,一個模型本身會要滿足幾個條件:

  1. https://chart.googleapis.com/chart?cht=tx&chl=%5Clambda-contractive
  2. additional smoothness
  3. Lipschitz assumptions

這幾個條件簡單來說,就是你的 loss function 需要是平滑的,那麼你的梯度就不會起伏太大,導致梯度爆炸或是消失的狀況。在這樣的狀況下,就可以用 feed-forward network 去逼近。

Feed-forward network 逼近

動畫取自 WaveNet 官網

那用 feed-forward network 去逼近有什麼好處呢?

文章中提到三大好處:

  1. 平行化:你可以善用 GPU 加速
  2. 可訓練:以往 RNN 都不好訓練,但是如果可以換成 feed-forward network 就會比較容易訓練起來
  3. 推論速度:在速度上更快

近年來非常多的模型都採用了 auto-regressive 的架構,從前面提到的 Transformer,到新版的 Google 小姐 - WaveNet 都用了這樣的架構。


上一篇
28 Transformer
下一篇
30 結語
系列文
機器學習模型圖書館:從傳統模型到深度學習31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言