日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人文社科 > 生活经验 >内容正文

生活经验

最优化方法系列:Adam+SGD-AMSGrad 重点

發(fā)布時(shí)間:2023/11/28 生活经验 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 最优化方法系列:Adam+SGD-AMSGrad 重点 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

https://blog.csdn.net/wishchin/article/details/80567558

?

? ? ? ? 自動(dòng)調(diào)參的Adam方法已經(jīng)非常給力了,不過(guò)這主要流行于工程界,在大多數(shù)科學(xué)實(shí)驗(yàn)室中,模型調(diào)參依然使用了傳統(tǒng)的SGD方法,在SGD基礎(chǔ)上增加各類學(xué)習(xí)率的主動(dòng)控制,以達(dá)到對(duì)復(fù)雜模型的精細(xì)調(diào)參,以達(dá)到刷出最高的分?jǐn)?shù)。

?????? ? ICLR會(huì)議的 On the convergence of Adam and Beyond 論文,對(duì)Adam算法進(jìn)行了 猛烈的抨擊,并提出了新的Adam算法變體。

???????? 以前的文章:最優(yōu)化方法之GD、SGD?;最優(yōu)化之回歸/擬合方法總結(jié);最優(yōu)化方法之SGD、Adams;

???????? 參考文章:GD優(yōu)化算法總結(jié)--,可見每一步公式的更新都來(lái)之不易。

???????? 優(yōu)化方法總結(jié):??SGD,Momentum,AdaGrad,RMSProp,Adam.這一篇文章描述簡(jiǎn)介.

?????? 整個(gè)優(yōu)化系列文章列表:Deep Learning 之 最優(yōu)化方法;Deep Learning 最優(yōu)化方法之SGD;Deep Learning 最優(yōu)化方法之Momentum(動(dòng)量);Deep Learning 最優(yōu)化方法之Nesterov(牛頓動(dòng)量);Deep Learning 最優(yōu)化方法之AdaGrad;Deep Learning 最優(yōu)化方法之RMSProp;Deep Learning 最優(yōu)化方法之Adam;

???????? 按章節(jié)翻譯的中文版-DLBook中文版:https://github.com/exacity/deeplearningbook-chinese

?

Adams算法

?? ?? 先上結(jié)論:

?? ? 1.Adam算法可以看做是修正后的Momentum+RMSProp算法

?? ? 2.動(dòng)量直接并入梯度一階矩估計(jì)中(指數(shù)加權(quán))

???? 3.Adam通常被認(rèn)為對(duì)超參數(shù)的選擇相當(dāng)魯棒

???? 4.學(xué)習(xí)率建議為0.001

再看算法:其實(shí)就是Momentum+RMSProp的結(jié)合,然后再修正其偏差。

???

?

Adams問(wèn)題

參考:Adams那么棒,為什么對(duì)SGD念念不忘-2 ?

1.Adams可能不收斂

文中各大優(yōu)化算法的學(xué)習(xí)率:

???????

其中,SGD沒(méi)有用到二階動(dòng)量,因此學(xué)習(xí)率是恒定的(實(shí)際使用過(guò)程中會(huì)采用學(xué)習(xí)率衰減策略,因此學(xué)習(xí)率遞減)。AdaGrad的二階動(dòng)量不斷累積,單調(diào)遞增,因此學(xué)習(xí)率是單調(diào)遞減的。因此,這兩類算法會(huì)使得學(xué)習(xí)率不斷遞減,最終收斂到0,模型也得以收斂。

但AdaDelta和Adam則不然。二階動(dòng)量是固定時(shí)間窗口內(nèi)的累積,隨著時(shí)間窗口的變化,遇到的數(shù)據(jù)可能發(fā)生巨變,使得??可能會(huì)時(shí)大時(shí)小,不是單調(diào)變化。這就可能在訓(xùn)練后期引起學(xué)習(xí)率的震蕩,導(dǎo)致模型無(wú)法收斂。

2.Adams可能錯(cuò)失全局最優(yōu)解

?????? 吐槽Adam最狠的?The Marginal Value of Adaptive Gradient Methods in Machine Learning?。文中說(shuō)到,同樣的一個(gè)優(yōu)化問(wèn)題,不同的優(yōu)化算法可能會(huì)找到不同的答案,但自適應(yīng)學(xué)習(xí)率的算法往往找到非常差的答案。他們通過(guò)一個(gè)特定的數(shù)據(jù)例子說(shuō)明,自適應(yīng)學(xué)習(xí)率算法可能會(huì)對(duì)前期出現(xiàn)的特征過(guò)擬合,后期才出現(xiàn)的特征很難糾正前期的擬合效果。

?

Adams變體方法改進(jìn)

????? 會(huì)議評(píng)論: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ù)移動(dòng)平均值的RMSProp公式有缺陷,,基本表現(xiàn)了“自適應(yīng)學(xué)習(xí)率”優(yōu)化算法的學(xué)習(xí)率的倒數(shù)相對(duì)于時(shí)間的變化。 對(duì)于SGD和ADAGRAD而言,當(dāng)t ∈ [T]時(shí),Γt始終大于等于0。這是它們的基本梯度更新規(guī)則,所以它們的學(xué)習(xí)率始終是單調(diào)遞減的。但是基于指數(shù)移動(dòng)平均值的RMSProp和Adam卻沒(méi)法保證這一點(diǎn),當(dāng)t ∈ [T]時(shí),它們的Γt可能大于等于0,也可能小于0。這種現(xiàn)象會(huì)導(dǎo)致學(xué)習(xí)率反復(fù)震蕩,繼而使模型無(wú)法收斂。

???????? 以F = [?1, 1]的簡(jiǎn)單分段線性函數(shù)為例:??。當(dāng)C > 2,在這個(gè)函數(shù)中,我們很輕松就能看出它應(yīng)收斂于x = ?1。但如果用Adam,它的二階動(dòng)量超參數(shù)分別是β1 = 0,β2 = 1/(1 + C2),算法會(huì)收斂在x = +1這個(gè)點(diǎn)。我們直觀推理下:該算法每3步計(jì)算一次梯度和,如果其中兩步得出的結(jié)論是x = -1,而一次得出的結(jié)論是C,那么計(jì)算指數(shù)移動(dòng)平均值后,算法就會(huì)偏離正確收斂方向。因?yàn)閷?duì)于給定的超參數(shù)β2,大梯度C沒(méi)法控制自己帶來(lái)的不良影響。

?

2.來(lái)看一個(gè)各個(gè)優(yōu)化算法在最優(yōu)解和鞍點(diǎn)附近的迭代求解圖。

??

???????????????????????????????????????????? 圖片來(lái)源:http://imgur.com/a/Hqolp

從上圖來(lái)看,似乎SGD是一種 “最蠢”的方法,不過(guò)文獻(xiàn)《The Marginal Value of Adaptive Gradient Methods in Machine Learning》給出的結(jié)論卻是:

?????? 自適應(yīng)優(yōu)化算法訓(xùn)練出來(lái)的結(jié)果通常都不如SGD,盡管這些自適應(yīng)優(yōu)化算法在訓(xùn)練時(shí)表現(xiàn)的看起來(lái)更好。 使用者應(yīng)當(dāng)慎重使用自適應(yīng)優(yōu)化算法。自適應(yīng)算法類似于過(guò)學(xué)習(xí)的效果,生成的模型面對(duì)整體分布時(shí)是過(guò)擬合的。

?????? 作者這樣闡述: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.這一點(diǎn)貌似不是主要的Adam的缺點(diǎn)。

?

Adams變體AMSGrad

??????? RMSProp和Adam算法下的Γt可能是負(fù)的,所以文章探討了一種替代方法,通過(guò)把超參數(shù)β1、β2設(shè)置為隨著t變化而變化,從而保證Γt始終是個(gè)非負(fù)數(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.

???????? 通過(guò)添加額外的約束,使學(xué)習(xí)率始終為正值,當(dāng)然代價(jià)是在大多數(shù)時(shí)候,AMSGrad算法的學(xué)習(xí)率是小于Adams和Rmsprop的。它們的主要區(qū)別在于AMSGrad記錄的是迄今為止所有梯度值vt中的最大值,并用它來(lái)更新學(xué)習(xí)率,而Adam用的是平均值。因此當(dāng)t ∈ [T]時(shí),AMSGrad的Γt也能做到始終大于等于0。

???????? 實(shí)驗(yàn)結(jié)果

?????????

?

??????

?

多種方法結(jié)合

?????? 論文?Improving Generalization Performance by Switching from Adam to SGD,進(jìn)行了實(shí)驗(yàn)驗(yàn)證。他們CIFAR-10數(shù)據(jù)集上進(jìn)行測(cè)試,Adam的收斂速度比SGD要快,但最終收斂的結(jié)果并沒(méi)有SGD好。他們進(jìn)一步實(shí)驗(yàn)發(fā)現(xiàn),主要是后期Adam的學(xué)習(xí)率太低,影響了有效的收斂。他們?cè)囍鴮?duì)Adam的學(xué)習(xí)率的下界進(jìn)行控制,發(fā)現(xiàn)效果好了很多。

??????? 于是他們提出了一個(gè)用來(lái)改進(jìn)Adam的方法:前期用Adam,享受Adam快速收斂的優(yōu)勢(shì);后期切換到SGD,慢慢尋找最優(yōu)解。這一方法以前也被研究者們用到,不過(guò)主要是根據(jù)經(jīng)驗(yàn)來(lái)選擇切換的時(shí)機(jī)和切換后的學(xué)習(xí)率。這篇文章把這一切換過(guò)程傻瓜化,給出了切換SGD的時(shí)機(jī)選擇方法,以及學(xué)習(xí)率的計(jì)算方法,效果看起來(lái)也不錯(cuò)。

??????? 時(shí)機(jī)很重要,把自適應(yīng)變化為分析數(shù)據(jù)后,固定優(yōu)化函數(shù)手動(dòng)切換,理論上能取得更好的效果。又或者,修改Adams算法,以應(yīng)對(duì)Novel情況,保證它的收斂性。

?

總結(jié)

以上是生活随笔為你收集整理的最优化方法系列:Adam+SGD-AMSGrad 重点的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。