概要
Pytorch で使用できる最適化アルゴリズム AdaGrad、RMSProp、RMSpropGraves、Adadelta について解説します。
AdaGrad はこれまでのステップの勾配の大きさを記録し、学習率を調整するアルゴリズムです。
Optimizer の状態
input : γ (lr) , θ (params) , f ( θ ) (objective) τ (initial accumulator value) , η (lr decay) initialize : s t a t e _ s u m 0 ← τ , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t – 1 ) γ ~ ← γ 1 + ( t – 1 ) η s t a t e _ s u m t ← s t a t e _ s u m t – 1 + g t 2 θ t ← θ t – 1 – γ ~ g t s t a t e _ s u m t + ϵ r e t u r n θ t
\begin{aligned}
%入力
&\rule{110mm}{0.4pt} \\
&\textbf{input} :
\gamma \text{ (lr)}, \:
\theta \text{ (params)}, \:
f(\theta) \text{ (objective)} \\
&\hspace{15mm}
\tau \text{ (initial accumulator value)}, \:
\eta\text{ (lr decay)}\\
%初期化
&\textbf{initialize} :
state\_sum_0 \leftarrow \tau,
\theta_0 \leftarrow \text{initial value} \\
%アルゴリズム
&\rule{110mm}{0.4pt} \\
&\textbf{for} \: t=1 \: \textbf{to} \: \ldots \: \textbf{do} \\
&\hspace{5mm} g_t \leftarrow \nabla_{\theta} f_t (\theta_{t – 1}) \\
&\hspace{5mm} \tilde{\gamma} \leftarrow \frac{\gamma}{1 + (t – 1) \eta} \\
&\hspace{5mm} state\_sum_t \leftarrow state\_sum_{t – 1} + g^2_t \\
&\hspace{5mm} \theta_t \leftarrow \theta_{t – 1} – \tilde{\gamma} \frac{g_t}{\sqrt{state\_sum_t}+\epsilon} \\
&\rule{110mm}{0.4pt} \\
&\bf{return} \: \theta_t \\
&\rule{110mm}{0.4pt} \\
\end{aligned}
input : γ (lr) , θ (params) , f ( θ ) (objective) τ (initial accumulator value) , η (lr decay) initialize : s t a t e _ s u m 0 ← τ , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t –1 ) γ ~ ← 1 + ( t –1 ) η γ s t a t e _ s u m t ← s t a t e _ s u m t –1 + g t 2 θ t ← θ t –1 – γ ~ s t a t e _ s u m t + ϵ g t return θ t
学習率の減衰率が η > 0 \eta > 0 η > 0 の場合、学習率はステップごとに減衰します。
γ ~ ← γ 1 + ( t – 1 ) η
\tilde{\gamma} \leftarrow \frac{\gamma}{1 + (t – 1) \eta}
γ ~ ← 1 + ( t –1 ) η γ
s t a t e _ s u m t state\_sum_t s t a t e _ s u m t は勾配の二乗のステップ t t t までの総和です。勾配の大きさを記録するのが目的のため、二乗をとっています。
s t a t e _ s u m t = s t a t e _ s u m t − 1 + g t 2 = ∑ i = 0 t g t 2
state\_sum_t = state\_sum_{t-1} + g^2_t
= \sum_{i = 0}^t g^2_t
s t a t e _ s u m t = s t a t e _ s u m t − 1 + g t 2 = i = 0 ∑ t g t 2 γ ~ \tilde{\gamma} γ ~ を s t a t e _ s u m t \sqrt{state\_sum_t} s t a t e _ s u m t で割ることで学習率を調整します。序盤は s t a t e _ s u m t state\_sum_t s t a t e _ s u m t が小さいため調整後の学習率は大きくなり、終盤は s t a t e _ s u m t state\_sum_t s t a t e _ s u m t が大きいため調整後の学習率は小さくなります。ϵ \epsilon ϵ は s t a t e _ s u m t state\_sum_t s t a t e _ s u m t の値が小さい序盤に、除算結果が大きくなりすぎないように調整するための係数です。
θ t ← θ t – 1 – g t γ ~ s t a t e _ s u m t + ϵ
\theta_t \leftarrow
\theta_{t – 1} – g_t \frac{\tilde{\gamma}}{\sqrt{state\_sum_t} + \epsilon}
θ t ← θ t –1 – g t s t a t e _ s u m t + ϵ γ ~ AdaGrad の欠点として、序盤の勾配が大きい場合に、学習が途中の段階で、調整後の学習率が小さくなってしまい、パラメータがほとんど更新されなくなることがあります。
以下は f ( x , y ) = 0.1 ∗ x 2 + y 2 f(x, y) = 0.1 * x^2 + y^2 f ( x , y ) = 0.1 ∗ x 2 + y 2 という関数を lr=1.0
の AdaGrad で最適化した結果になります。
以下は s t a t e _ d i c t state\_dict s t a t e _ d i c t の値の推移です。x 2 x_2 x 2 方向は序盤の勾配が急のため、s t a t e _ d i c t state\_dict s t a t e _ d i c t の値が急に大きくなっています。
以下は調整後の学習率の値の推移です。x 2 x_2 x 2 方向の s t a t e _ d i c t state\_dict s t a t e _ d i c t に応じて学習率が調整されていることがわかります。
AdaGrad では、勾配の二乗のステップ t t t までの総和を計算し、その平方根で除算していたため、過去の勾配の大きさはすべて等しく学習率の調整に影響を与えていました。一方、RMSprop では、勾配の二乗のステップ t t t までの指数移動平均を計算します。指数移動平均のため、直近のステップの勾配の大きさがより重視されるようになります。
Optimizer の状態
input : α (alpha) , γ (lr) , θ (params) , f ( θ ) (objective) μ (momentum) initialize : v 0 ← 0 (square average) , b 0 ← 0 (buffer) , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t – 1 ) v t ← α v t – 1 + ( 1 – α ) g t 2 i f μ > 0 b t ← μ b t − 1 + g t v t + ϵ θ t ← θ t – 1 – γ b t e l s e θ t ← θ t – 1 – γ g t v t + ϵ r e t u r n θ t
\begin{aligned}
%入力
&\rule{110mm}{0.4pt} \\
&\textbf{input} :
\alpha \text{ (alpha)}, \:
\gamma \text{ (lr)}, \:
\theta \text{ (params)}, \:
f(\theta) \text{ (objective)} \\
&\hspace{15mm}
\mu \text{ (momentum)} \\
%初期化
&\textbf{initialize} :
v_0 \leftarrow 0 \text{ (square average)}, \:
\textbf{b}_0 \leftarrow 0 \text{ (buffer)}, \:
\theta_0 \leftarrow \text{initial value} \\
%アルゴリズム
&\rule{110mm}{0.4pt} \\
&\textbf{for} \: t=1 \: \textbf{to} \: \ldots \: \textbf{do} \\
&\hspace{5mm}g_t \leftarrow \nabla_{\theta} f_t (\theta_{t – 1}) \\
&\hspace{5mm}v_t \leftarrow \alpha v_{t – 1} + (1 – \alpha) g^2_t \\
&\hspace{5mm}if \: \mu > 0 \\
&\hspace{10mm} \textbf{b}_t\leftarrow \mu \textbf{b}_{t-1} +
\frac{g_t}{\sqrt{v_t} + \epsilon} \\
&\hspace{10mm} \theta_t \leftarrow \theta_{t – 1} – \gamma \textbf{b}_t \\
&\hspace{5mm} else \\
&\hspace{10mm}\theta_t \leftarrow \theta_{t – 1} –
\gamma \frac{g_t}{\sqrt{v_t} + \epsilon} \hspace{3mm} \\
%出力
&\rule{110mm}{0.4pt} \\
&\bf{return} \: \theta_t \\
&\rule{110mm}{0.4pt} \\
\end{aligned}
input : α (alpha) , γ (lr) , θ (params) , f ( θ ) (objective) μ (momentum) initialize : v 0 ← 0 (square average) , b 0 ← 0 (buffer) , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t –1 ) v t ← α v t –1 + ( 1– α ) g t 2 i f μ > 0 b t ← μ b t − 1 + v t + ϵ g t θ t ← θ t –1 – γ b t e l se θ t ← θ t –1 – γ v t + ϵ g t return θ t
勾配の二乗の指数移動平均をとります。α \alpha α の値が小さいほど過去の勾配の影響が弱くなります。
v t ← α v t − 1 + ( 1 – α ) g t 2
v_t \leftarrow \alpha v_{t-1} + (1 – \alpha) g^2_t
v t ← α v t − 1 + ( 1– α ) g t 2
以下は f ( x , y ) = 0.1 ∗ x 2 + y 2 f(x, y) = 0.1 * x^2 + y^2 f ( x , y ) = 0.1 ∗ x 2 + y 2 という関数を lr=0.1, alpha=0.9
の RMSprop で最適化した結果になります。
以下は v t v_t v t の値の推移です。移動指数平均なので、序盤の勾配が急なところで大きくなったあと、徐々に小さくなっているのがわかります。
以下は調整後の学習率の値の推移です。v t v_t v t の値に応じて学習率が調整されていることがわかります。
RMSpropGraves
centerd=True
の場合、RMSpropGraves という RMSProp の改良版になります。RMSprop との違いは、勾配の二乗の指数移動平均から勾配の指数移動平均を減算するように変更されている点です。
Optimizer の状態
input : α (alpha) , γ (lr) , θ (params) , f ( θ ) (objective) λ (weight decay) , μ (momentum) initialize : v 0 ← 0 (square average) , b 0 ← 0 (buffer) , g 0 a v e ← 0 , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t – 1 ) v t ← α v t – 1 + ( 1 – α ) g t 2 g t a v e ← α g t – 1 a v e + ( 1 – α ) g t v t ~ ← v t ~ – ( g t a v e ) 2 i f μ > 0 b t ← μ b t – 1 + g t v t ~ + ϵ θ t ← θ t – 1 – γ b t e l s e θ t ← θ t – 1 – γ g t v t ~ + ϵ r e t u r n θ t
\begin{aligned}
%入力
&\rule{110mm}{0.4pt} \\
&\textbf{input} :
\alpha \text{ (alpha)}, \:
\gamma \text{ (lr)}, \:
\theta \text{ (params)}, \:
f(\theta) \text{ (objective)} \\
&\hspace{15mm}
\lambda \text{ (weight decay)}, \:
\mu \text{ (momentum)} \\
%初期化
&\textbf{initialize} :
v_0 \leftarrow 0 \text{ (square average)}, \:
\textbf{b}_0 \leftarrow 0 \text{ (buffer)}, \:
g^{ave}_0 \leftarrow 0, \: \\
&\hspace{20mm}
\theta_0 \leftarrow \text{initial value} \\
%アルゴリズム
&\rule{110mm}{0.4pt} \\
&\textbf{for} \: t=1 \: \textbf{to} \: \ldots \: \textbf{do} \\
&\hspace{5mm}g_t \leftarrow \nabla_{\theta} f_t (\theta_{t – 1}) \\
&\hspace{5mm}v_t \leftarrow \alpha v_{t – 1} + (1 – \alpha) g^2_t \\
&\hspace{5mm} g^{ave}_t \leftarrow \alpha g^{ave}_{t – 1} + (1 – \alpha) g_t \\
&\hspace{5mm} \tilde{v_t} \leftarrow \tilde{v_t} – \big(g^{ave}_{t} \big)^2 \\
&\hspace{5mm}if \: \mu > 0 \\
&\hspace{10mm} \textbf{b}_t\leftarrow \mu \textbf{b}_{t – 1} +
\frac{g_t}{\sqrt{\tilde{v_t}} + \epsilon} \\
&\hspace{10mm} \theta_t \leftarrow \theta_{t – 1} – \gamma \textbf{b}_t \\
&\hspace{5mm} else \\
&\hspace{10mm}\theta_t \leftarrow \theta_{t – 1} –
\gamma \frac{g_t}{\sqrt{\tilde{v_t}} + \epsilon} \hspace{3mm} \\
%出力
&\rule{110mm}{0.4pt} \\
&\bf{return} \: \theta_t \\
&\rule{110mm}{0.4pt} \\
\end{aligned}
input : α (alpha) , γ (lr) , θ (params) , f ( θ ) (objective) λ (weight decay) , μ (momentum) initialize : v 0 ← 0 (square average) , b 0 ← 0 (buffer) , g 0 a v e ← 0 , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t –1 ) v t ← α v t –1 + ( 1– α ) g t 2 g t a v e ← α g t –1 a v e + ( 1– α ) g t v t ~ ← v t ~ – ( g t a v e ) 2 i f μ > 0 b t ← μ b t –1 + v t ~ + ϵ g t θ t ← θ t –1 – γ b t e l se θ t ← θ t –1 – γ v t ~ + ϵ g t return θ t
Adadelta は AdaGrad の以下の欠点を改善したアルゴリズムです。
学習途中で学習率が小さくなってしまう
ベースの学習率を設定する必要がある
Adadelta の論文に記載されているアルゴリズムでは、学習率は存在しませんが、Pytorch では API の便宜上、Adadelta によって決定された学習率にスケールするためのパラメータとして lr
が残っています。lr=1
とすれば、論文と同じアルゴリズムになります。
Optimizer の状態
input : γ (lr) , θ (params) , f ( θ ) (objective) , ρ (decay) initialize : v 0 ← 0 (square avg) , u 0 ← 0 (accumulate variables) , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t – 1 ) v t ← ρ v t – 1 + ( 1 – ρ ) g t 2 Δ x t ← u t – 1 + ϵ v t + ϵ g t u t ← ρ u t – 1 + ( 1 – ρ ) Δ x t 2 θ t ← θ t – 1 – γ Δ x t r e t u r n θ t
\begin{aligned}
%入力
&\rule{110mm}{0.4pt} \\
&\textbf{input} :
\gamma \text{ (lr)}, \:
\theta \text{ (params)}, \:
f(\theta) \text{ (objective)}, \:
\rho \text{ (decay)} \\
%初期化
&\textbf{initialize} :
v_0 \leftarrow 0 \: \text{ (square avg)},
\: u_0 \leftarrow 0 \: \text{ (accumulate variables)}, \:
\theta_0 \leftarrow \text{initial value} \\
%アルゴリズム
&\rule{110mm}{0.4pt} \\
&\textbf{for} \: t=1 \: \textbf{to} \: \ldots \: \textbf{do} \\
&\hspace{5mm} g_t \leftarrow \nabla_{\theta} f_t (\theta_{t – 1}) \\
&\hspace{5mm} v_t \leftarrow \rho v_{t – 1} + (1 – \rho) g^2_t \\
&\hspace{5mm} \Delta x_t \leftarrow \frac{\sqrt{u_{t – 1} +
\epsilon }}{ \sqrt{v_t + \epsilon} }g_t \\
&\hspace{5mm} u_t \leftarrow \rho u_{t – 1} +
(1 – \rho) \Delta x^2_t \\
&\hspace{5mm}\theta_t \leftarrow \theta_{t – 1} – \gamma \Delta x_t \\
&\rule{110mm}{0.4pt} \\
&\bf{return} \: \theta_t \\
&\rule{110mm}{0.4pt} \\
\end{aligned}
input : γ (lr) , θ (params) , f ( θ ) (objective) , ρ (decay) initialize : v 0 ← 0 (square avg) , u 0 ← 0 (accumulate variables) , θ 0 ← initial value for t = 1 to … do g t ← ∇ θ f t ( θ t –1 ) v t ← ρ v t –1 + ( 1– ρ ) g t 2 Δ x t ← v t + ϵ u t –1 + ϵ g t u t ← ρ u t –1 + ( 1– ρ ) Δ x t 2 θ t ← θ t –1 – γ Δ x t return θ t
学習途中で学習率が小さくなってしまう問題に関しては、RMSProp 同様、勾配の二乗和ではなく、勾配の移動指数平均を計算するように変更することで対策しました。
v t ← ρ v t – 1 + ( 1 – ρ ) g t 2
v_t \leftarrow \rho v_{t – 1} + (1 – \rho) g^2_t
v t ← ρ v t –1 + ( 1– ρ ) g t 2
分母の u t – 1 + ϵ \sqrt{u_{t – 1} + \epsilon} u t –1 + ϵ は更新量の単位をパラメータと合わせて、学習率の設定を不要にするためについています。
パラメータがそれぞれ仮想の単位を持っていると仮定したとき、パラメータの変化量はパラメータの単位に合わせて行われるべきです。
次元解析 の考え方を取り入れて、SGD や AdaGrad、RMSprop の更新式を考察してみます。
SGD の次元解析
θ t ← θ t – 1 – γ ∇ θ f t ( θ t – 1 )
\theta_t \leftarrow \theta_{t – 1} – \gamma \nabla_{\theta} f_t (\theta_{t – 1}) \\
θ t ← θ t –1 – γ ∇ θ f t ( θ t –1 ) Δ θ t = θ t – θ t – 1 \Delta \theta_t = \theta_t – \theta_{t – 1} Δ θ t = θ t – θ t –1 とし、f f f の単位は無次元量であると仮定したとき、( units of ∇ θ f ( θ ) ) = 1 ( units of θ ) (\text{units of } \nabla_{\theta} f (\theta)) = \frac{1}{(\text{units of } \theta)} ( units of ∇ θ f ( θ )) = ( units of θ ) 1 であるから、
( units of Δ θ ) = ( units of γ ∇ θ f ( θ ) ) = ( units of γ ) ( units of θ )
(\text{units of } \Delta \theta)
= \big(\text{units of } \gamma \nabla_{\theta} f (\theta) \big)
= \frac{(\text{units of } \gamma)}{(\text{units of } \theta)}
( units of Δ θ ) = ( units of γ ∇ θ f ( θ ) ) = ( units of θ ) ( units of γ ) パラメータの更新量の単位 ( units of Δ θ ) (\text{units of } \Delta \theta) ( units of Δ θ ) をパラメータの単位 ( units of θ ) (\text{units of } \theta) ( units of θ ) に合わせるには、学習率の単位を
( units of γ ) = ( units of θ ) 2
(\text{units of } \gamma) = (\text{units of } \theta)^2
( units of γ ) = ( units of θ ) 2 として単位を調整する必要があります。
AdaGrad、RMSprop の次元解析
g t ← ∇ θ f t ( θ t – 1 ) γ ~ ← γ 1 + ( t – 1 ) η s t a t e _ s u m t ← s t a t e _ s u m t – 1 + g t 2 θ t ← θ t – 1 – γ ~ g t s t a t e _ s u m t + ϵ
\begin{aligned}
&g_t \leftarrow \nabla_{\theta} f_t (\theta_{t – 1}) \\
&\tilde{\gamma} \leftarrow \frac{\gamma}{1 + (t – 1) \eta} \\
&state\_sum_t \leftarrow state\_sum_{t – 1} + g^2_t \\
&\theta_t \leftarrow \theta_{t – 1} – \tilde{\gamma} \frac{g_t}{\sqrt{state\_sum_t}+\epsilon} \\
\end{aligned}
g t ← ∇ θ f t ( θ t –1 ) γ ~ ← 1 + ( t –1 ) η γ s t a t e _ s u m t ← s t a t e _ s u m t –1 + g t 2 θ t ← θ t –1 – γ ~ s t a t e _ s u m t + ϵ g t Δ θ t = θ t – θ t – 1 \Delta \theta_t = \theta_t – \theta_{t – 1} Δ θ t = θ t – θ t –1 とし、f , ϵ , η f, \epsilon, \eta f , ϵ , η の単位は無次元量であると仮定したとき、( units of s t a t e _ s u m ) = 1 ( units of θ ) 2 (\text{units of } state\_sum) = \frac{1}{(\text{units of } \theta)^2} ( units of s t a t e _ s u m ) = ( units of θ ) 2 1 であるから、
( units of Δ θ ) = ( units of γ ~ ) 1 ( units of θ ) ( units of θ )
(\text{units of } \Delta \theta)
= (\text{units of } \tilde{\gamma})
\frac{1}{(\text{units of } \theta)} (\text{units of } \theta)
( units of Δ θ ) = ( units of γ ~ ) ( units of θ ) 1 ( units of θ ) パラメータの更新量の単位 ( units of Δ θ ) (\text{units of } \Delta \theta) ( units of Δ θ ) をパラメータの単位 ( units of θ ) (\text{units of } \theta) ( units of θ ) に合わせるには、学習率の単位を
( units of γ ) = ( units of θ )
(\text{units of } \gamma) = (\text{units of } \theta)
( units of γ ) = ( units of θ ) として単位を調整する必要があります。RMSprop の v v v も勾配の二乗の指数移動平均なので、AdaGrad と同じです。
ニュートン法の次元解析を元にした AdaDelta の単位合わせ
ニュートン法の更新量は
Δ θ = – H − 1 ∇ θ f ( θ )
\Delta \theta = – H^{-1} \nabla_\theta f(\theta)
Δ θ = – H − 1 ∇ θ f ( θ ) です。ただし、H H H はヘッセ行列を表します。
次元解析を行うと、f f f の単位は無次元量であると仮定したとき、
( units of Δ θ ) = ( units of H − 1 ) ( units of ∇ θ f ( θ ) ) ( units of H − 1 ) = ( units of Δ θ ) ( units of ∇ θ f ( θ ) )
\begin{aligned}
(\text{units of } \Delta \theta) &= (\text{units of } H^{-1}) (\text{units of } \nabla_\theta f(\theta)) \\
(\text{units of } H^{-1}) &= \frac{(\text{units of } \Delta \theta)}{(\text{units of } \nabla_\theta f(\theta))}
\end{aligned}
( units of Δ θ ) ( units of H − 1 ) = ( units of H − 1 ) ( units of ∇ θ f ( θ )) = ( units of ∇ θ f ( θ )) ( units of Δ θ ) これをニュートン法の更新量の式に代入して、
( units of Δ θ ) = ( units of Δ θ ) ( units of ∇ θ f ( θ ) ) ( units of ∇ θ f ( θ ) )
(\text{units of } \Delta \theta) = \frac{(\text{units of } \Delta \theta)}{(\text{units of } \nabla_\theta f(\theta))} (\text{units of } \nabla_\theta f(\theta))
( units of Δ θ ) = ( units of ∇ θ f ( θ )) ( units of Δ θ ) ( units of ∇ θ f ( θ )) Adadelta では、分子に単位を揃えるために Δ θ \Delta \theta Δ θ の二乗のステップ t t t までの二乗の移動指数平均 u t u_t u t を計算し、その値を分母に追加しています。
Δ x t ← u t – 1 + ϵ v t + ϵ g t
\Delta x_t \leftarrow \frac{\sqrt{u_{t – 1} + \epsilon }}{ \sqrt{v_t + \epsilon} }g_t
Δ x t ← v t + ϵ u t –1 + ϵ g t しかし、Δ x t \Delta x_t Δ x t を計算する段階では、u t u_t u t はまだわからないので、代わりに Δ x t \Delta x_t Δ x t は滑らかに変化するという仮定をおいて、1つ前のステップの u t – 1 u_{t – 1} u t –1 で近似します。Δ x t \Delta x_t Δ x t が計算できたら、移動指数平均 u t u_t u t を更新します。
u t ← ρ u t – 1 + ( 1 – ρ ) Δ x t 2
u_t \leftarrow \rho u_{t – 1} + (1 – \rho) \Delta x^2_t
u t ← ρ u t –1 + ( 1– ρ ) Δ x t 2
AdaDelta の次元解析
g t ← ∇ θ f t ( θ t – 1 ) v t ← ρ v t – 1 + ( 1 – ρ ) g t 2 Δ x t ← u t – 1 + ϵ v t + ϵ g t u t ← ρ u t – 1 + ( 1 – ρ ) Δ x t 2 θ t ← θ t – 1 – γ Δ x t
\begin{aligned}
&g_t \leftarrow \nabla_{\theta} f_t (\theta_{t – 1}) \\
&v_t \leftarrow \rho v_{t – 1} + (1 – \rho) g^2_t \\
&\Delta x_t \leftarrow \frac{\sqrt{u_{t – 1} +
\epsilon }}{ \sqrt{v_t + \epsilon} }g_t \\
&u_t \leftarrow \rho u_{t – 1} +
(1 – \rho) \Delta x^2_t \\
&\theta_t \leftarrow \theta_{t – 1} – \gamma \Delta x_t \\
\end{aligned}
g t ← ∇ θ f t ( θ t –1 ) v t ← ρ v t –1 + ( 1– ρ ) g t 2 Δ x t ← v t + ϵ u t –1 + ϵ g t u t ← ρ u t –1 + ( 1– ρ ) Δ x t 2 θ t ← θ t –1 – γ Δ x t Δ θ t = θ t – θ t – 1 \Delta \theta_t = \theta_t – \theta_{t – 1} Δ θ t = θ t – θ t –1 とし、f , ϵ , ρ , γ f, \epsilon, \rho, \gamma f , ϵ , ρ , γ の単位は無次元量であると仮定したとき、
( units of v ) = 1 ( units of θ ) 2 ( units of u ) = ( units of Δ θ ) 2
\begin{aligned}
(\text{units of } v) &= \frac{1}{(\text{units of } \theta)^2} \\
(\text{units of } u) &= (\text{units of } \Delta \theta)^2
\end{aligned}
( units of v ) ( units of u ) = ( units of θ ) 2 1 = ( units of Δ θ ) 2 であるから、
( units of Δ θ ) = ( units of u ) ( units of v ) ( units of g ) = ( units of Δ θ ) ( units of θ ) 1 ( units of θ ) = ( units of Δ θ )
\begin{aligned}
(\text{units of } \Delta \theta)
&= \frac{\sqrt{(\text{units of } u)}}{ \sqrt{(\text{units of } v)} } (\text{units of } g) \\
&= (\text{units of } \Delta \theta) (\text{units of } \theta)
\frac{1}{(\text{units of } \theta)} \\
&= (\text{units of } \Delta \theta)
\end{aligned}
( units of Δ θ ) = ( units of v ) ( units of u ) ( units of g ) = ( units of Δ θ ) ( units of θ ) ( units of θ ) 1 = ( units of Δ θ ) AdaDelta の更新式は左辺と右辺の単位が一致しているため、学習率で単位を調整する必要がありません。
以下は f ( x , y ) = 0.1 ∗ x 2 + y 2 f(x, y) = 0.1 * x^2 + y^2 f ( x , y ) = 0.1 ∗ x 2 + y 2 という関数を eps=1e-3
の Adadelta で最適化した結果になります。序盤で学習率が小さくなりすぎて更新されないのを防ぐ目的でデフォルト値より大きめの値を設定しました。
以下は v t , u t v_t, u_t v t , u t の値の推移です。移動指数平均なので、序盤の勾配が急なところで大きくなったあと、徐々に小さくなっているのがわかります。
以下は調整後の学習率の値の推移です。v t , u t v_t, u_t v t , u t の値に応じて学習率が調整されていることがわかります。
参考
コメント