最优化方法系列:Adam+SGD-AMSGrad
??????? 自動調(diào)參的Adam方法已經(jīng)非常給力了,不過這主要流行于工程界,在大多數(shù)科學實驗室中,模型調(diào)參依然使用了傳統(tǒng)的SGD方法,在SGD基礎上增加各類學習率的主動控制,以達到對復雜模型的精細調(diào)參,以達到刷出最高的分數(shù)。
?????? ? ICLR會議的 On the convergence of Adam and Beyond 論文,對Adam算法進行了 猛烈的抨擊,并提出了新的Adam算法變體。
???????? 以前的文章:最優(yōu)化方法之GD、SGD ;最優(yōu)化之回歸/擬合方法總結;最優(yōu)化方法之SGD、Adams;
???????? 參考文章:GD優(yōu)化算法總結--,可見每一步公式的更新都來之不易。
???????? 優(yōu)化方法總結:? SGD,Momentum,AdaGrad,RMSProp,Adam.這一篇文章描述簡介.
?????? 整個優(yōu)化系列文章列表:Deep Learning 之 最優(yōu)化方法;Deep Learning 最優(yōu)化方法之SGD;Deep Learning 最優(yōu)化方法之Momentum(動量);Deep Learning 最優(yōu)化方法之Nesterov(牛頓動量);Deep Learning 最優(yōu)化方法之AdaGrad;Deep Learning 最優(yōu)化方法之RMSProp;Deep Learning 最優(yōu)化方法之Adam;
???????? 按章節(jié)翻譯的中文版-DLBook中文版:https://github.com/exacity/deeplearningbook-chinese
?
Adams算法
?? ?? 先上結論:
?? ? 1.Adam算法可以看做是修正后的Momentum+RMSProp算法
?? ? 2.動量直接并入梯度一階矩估計中(指數(shù)加權)
???? 3.Adam通常被認為對超參數(shù)的選擇相當魯棒
???? 4.學習率建議為0.001
再看算法:其實就是Momentum+RMSProp的結合,然后再修正其偏差。
???
?
Adams問題
參考:Adams那么棒,為什么對SGD念念不忘-2 ?
1.Adams可能不收斂
文中各大優(yōu)化算法的學習率:
??????
其中,SGD沒有用到二階動量,因此學習率是恒定的(實際使用過程中會采用學習率衰減策略,因此學習率遞減)。AdaGrad的二階動量不斷累積,單調(diào)遞增,因此學習率是單調(diào)遞減的。因此,這兩類算法會使得學習率不斷遞減,最終收斂到0,模型也得以收斂。
但AdaDelta和Adam則不然。二階動量是固定時間窗口內(nèi)的累積,隨著時間窗口的變化,遇到的數(shù)據(jù)可能發(fā)生巨變,使得 可能會時大時小,不是單調(diào)變化。這就可能在訓練后期引起學習率的震蕩,導致模型無法收斂。
2.Adams可能錯失全局最優(yōu)解
?????? 吐槽Adam最狠的 The Marginal Value of Adaptive Gradient Methods in Machine Learning 。文中說到,同樣的一個優(yōu)化問題,不同的優(yōu)化算法可能會找到不同的答案,但自適應學習率的算法往往找到非常差的答案。他們通過一個特定的數(shù)據(jù)例子說明,自適應學習率算法可能會對前期出現(xiàn)的特征過擬合,后期才出現(xiàn)的特征很難糾正前期的擬合效果。
?
Adams變體方法改進
????? 會議評論:On the Convergence of Adam and Beyond ; 論文:https://openreview.net/pdf?id=ryQu7f-RZ 。
1. THE NON-CONVERGENCE OF ADAM
 ? ? ? With the problem setup in the previous section, we discuss fundamental flaw in the current exponential moving average methods like ADAM. We show that ADAM can fail to converge to an optimal solution even in simple one-dimensional convex settings. These examples of non-convergence contradict the claim of convergence in (Kingma & Ba, 2015), and the main issue lies in the following quantity of interest:
 ????????????????????????????????????? (2)
 ????? This quantity essentially measures the change in the inverse of learning rate of the adaptive method with respect to time. One key observation is that for SGD and ADAGRAD, -t 0 for all t 2 [T]. This simply follows from update rules of SGD and ADAGRAD in the previous section. Inparticular, update rules for these algorithms lead to “non-increasing” learning rates. However, this is not necessarily the case for exponential moving average variants like ADAM and RMSPROP i.e., -t can potentially be indefinite for t 2 [T] . We show that this violation of positive definiteness can? lead to undesirable convergence behavior for ADAM and RMSPROP. Consider the following simple sequence of linear functions for F = [-1,1]:
 ??????????? ? ? ? 
 ???? where C > 2. For this function sequence, it is easy to see that the point x = -1 provides the minimum regret. Suppose 1 = 0 and 2 = 1=(1 + C2). We show that ADAM converges to a highly suboptimal solution of x = +1 for this setting. Intuitively, the reasoning is as follows. The algorithm obtains the large gradient C once every 3 steps, and while the other 2 steps it observes the gradient -1, which moves the algorithm in the wrong direction. The large gradient C is unable to counteract this effect since it is scaled down by a factor of almost C for the given value of 2, and hence the algorithm converges to 1 rather than -1. We formalize this intuition in the result below.
Theorem 1. There is an online convex optimization problem where ADAM has non-zero average regret i.e., RT =T 9 0 as T ! 1.
 ?We relegate all proofs to the appendix.
?????? 使用指數(shù)移動平均值的RMSProp公式有缺陷,,基本表現(xiàn)了“自適應學習率”優(yōu)化算法的學習率的倒數(shù)相對于時間的變化。 對于SGD和ADAGRAD而言,當t ∈ [T]時,Γt始終大于等于0。這是它們的基本梯度更新規(guī)則,所以它們的學習率始終是單調(diào)遞減的。但是基于指數(shù)移動平均值的RMSProp和Adam卻沒法保證這一點,當t ∈ [T]時,它們的Γt可能大于等于0,也可能小于0。這種現(xiàn)象會導致學習率反復震蕩,繼而使模型無法收斂。
???????? 以F = [?1, 1]的簡單分段線性函數(shù)為例:? 。當C > 2,在這個函數(shù)中,我們很輕松就能看出它應收斂于x = ?1。但如果用Adam,它的二階動量超參數(shù)分別是β1 = 0,β2 = 1/(1 + C2),算法會收斂在x = +1這個點。我們直觀推理下:該算法每3步計算一次梯度和,如果其中兩步得出的結論是x = -1,而一次得出的結論是C,那么計算指數(shù)移動平均值后,算法就會偏離正確收斂方向。因為對于給定的超參數(shù)β2,大梯度C沒法控制自己帶來的不良影響。
?
2.來看一個各個優(yōu)化算法在最優(yōu)解和鞍點附近的迭代求解圖。
?
???????????????????????????????????????????? 圖片來源:http://imgur.com/a/Hqolp
從上圖來看,似乎SGD是一種 “最蠢”的方法,不過文獻《The Marginal Value of Adaptive Gradient Methods in Machine Learning》給出的結論卻是:
?????? 自適應優(yōu)化算法訓練出來的結果通常都不如SGD,盡管這些自適應優(yōu)化算法在訓練時表現(xiàn)的看起來更好。 使用者應當慎重使用自適應優(yōu)化算法。自適應算法類似于過學習的效果,生成的模型面對整體分布時是過擬合的。
?????? 作者這樣闡述:our experimental evidence demonstrates that adaptive methods are not advantageous for machine learning, the Adam algorithm remains incredibly popular. We are not sure exactly as to why, but hope that our step-size tuning suggestions make it easier for practitioners to use standard stochastic gradient methods in their research.這一點貌似不是主要的Adam的缺點。
?
Adams變體AMSGrad
??????? RMSProp和Adam算法下的Γt可能是負的,所以文章探討了一種替代方法,通過把超參數(shù)β1、β2設置為隨著t變化而變化,從而保證Γt始終是個非負數(shù)。
????? For the first part, we modify these algorithms to satisfy this additional constraint. Later on, we also explore an alternative approach where -t can be made positive semi-definite by using values of 1 and 2 that change with t.?????
???????
???????? AMSGRAD uses a smaller learning rate in comparison to ADAM and yet incorporates the intuition of slowly decaying the effect of past gradients on the learning rate as long as -t is positive semidefinite.
???????? 通過添加額外的約束,使學習率始終為正值,當然代價是在大多數(shù)時候,AMSGrad算法的學習率是小于Adams和Rmsprop的。它們的主要區(qū)別在于AMSGrad記錄的是迄今為止所有梯度值vt中的最大值,并用它來更新學習率,而Adam用的是平均值。因此當t ∈ [T]時,AMSGrad的Γt也能做到始終大于等于0。
???????? 實驗結果
????????
?
?????
?
多種方法結合
?????? 論文 Improving Generalization Performance by Switching from Adam to SGD,進行了實驗驗證。他們CIFAR-10數(shù)據(jù)集上進行測試,Adam的收斂速度比SGD要快,但最終收斂的結果并沒有SGD好。他們進一步實驗發(fā)現(xiàn),主要是后期Adam的學習率太低,影響了有效的收斂。他們試著對Adam的學習率的下界進行控制,發(fā)現(xiàn)效果好了很多。
??????? 于是他們提出了一個用來改進Adam的方法:前期用Adam,享受Adam快速收斂的優(yōu)勢;后期切換到SGD,慢慢尋找最優(yōu)解。這一方法以前也被研究者們用到,不過主要是根據(jù)經(jīng)驗來選擇切換的時機和切換后的學習率。這篇文章把這一切換過程傻瓜化,給出了切換SGD的時機選擇方法,以及學習率的計算方法,效果看起來也不錯。
??????? 時機很重要,把自適應變化為分析數(shù)據(jù)后,固定優(yōu)化函數(shù)手動切換,理論上能取得更好的效果。又或者,修改Adams算法,以應對Novel情況,保證它的收斂性。
?
總結
以上是生活随笔為你收集整理的最优化方法系列:Adam+SGD-AMSGrad的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 拼多多商家手机版app
 - 下一篇: 万象物语典藏琴谱怎么获得 万象网管吉胜科