最速下降法(欧式空间)

最速下降法(欧式空间)

一.欧式空间的最速下降法

给定一个函数 f ( x ) f(\mathbf x) f(x),我们的目标是找到一个方向使得 f ( x + Δ x ) f(\mathbf{x}+\Delta \mathbf x) f(x+Δx)最小,因我们关心的只是 Δ x \Delta \mathbf x Δx的方向,对于它的模(只要足够小)我们并不关心,可得以下最优化问题。
m i n m i z e     f ( x + Δ x ) s . t           ∣ ∣ Δ x ∣ ∣ p ≤ c lim ⁡ c → 0 (1-1) \begin{aligned} \mathrm{minmize} \ \ \ &f(\mathbf x+\Delta \mathbf x)\\ s.t\ \ \ \ \ \ \ \ \ &||\Delta \mathbf x||_p \leq c\\ &\lim c \rightarrow 0 \end{aligned} \tag{1-1} minmize   s.t         f(x+Δx)∣∣Δxpclimc0(1-1)
由于约束是在欧式空间中进行的,所以又称欧式空间中的最速下降法。

二.梯度下降法(一阶优化算法)

如果我们将p取为二范数,约束条件可以写为
Δ x T Δ x ≤ c lim ⁡ c → 0 (1-2) \Delta \mathbf x^T\Delta \mathbf x\leq c\\ \lim c \rightarrow 0 \tag{1-2} ΔxTΔxclimc0(1-2)
于是1-1的约束问题可以重写为
m i n m i z e     f ( x + Δ x )   s . t           ∣ ∣ Δ x ∣ ∣ 2 ≤ c lim ⁡ c → 0 (1-3) \begin{aligned} \mathrm{minmize} \ \ \ &f(\mathbf x+\Delta \mathbf x)\\\ s.t\ \ \ \ \ \ \ \ \ &||\Delta \mathbf x||^2 \leq c\\ &\lim c \rightarrow 0 \end{aligned} \tag{1-3} minmize    s.t         f(x+Δx)∣∣Δx2climc0(1-3)
引入拉格朗日乘子$\lambda \geq$0,拉格朗日函数为
L = f ( x + Δ x ) + λ ( Δ x T Δ x − c ) L=f(\mathbf x+\Delta \mathbf x)+\lambda(\Delta \mathbf x^T\Delta \mathbf x-c) L=f(x+Δx)+λ(ΔxTΔxc)
在极值处,应有 ∇ Δ x L = 0 \nabla _{\Delta\mathbf x}L=0 ΔxL=0,即可推出
∇ f ( x ) + 2 λ Δ x = 0      ( lim ⁡ Δ x → 0 )   (1-4) \nabla f(\mathbf x)+2\lambda \Delta \mathbf x=0\ \ \ \ (\lim \Delta x\rightarrow 0)\ \tag{1-4} f(x)+2λΔx=0    (limΔx0) (1-4)
由此得出 Δ x \Delta \mathbf x Δx的方向应该沿 f ( x ) f(\mathbf x) f(x)梯度的负方向。(由此我们可以说梯度下降是在二范数下的最优算法)

迭代公式
x k + 1 = x k − η ∇ f ( x k ) \mathbf x_{k+1}=\mathbf x_{k}-\eta\nabla f(\mathbf x_{k}) xk+1=xkηf(xk)

三.梯度下降收敛速度分析.

在分析收敛性之前先引入几个数学概念。

L i p s c h i t z Lipschitz Lipschitz连续函数 ∀ x , y ∈ R n , ∃ L ∈ R + , \forall \mathbf x,\mathbf y \in \Bbb R^n,\exist \mathit L\in \Bbb R^+, x,yRn,LR+,使得
∣ ∣ ∇ ( x ) − ∇ f ( y ) ∣ ∣ ≤ L ∣ ∣ x − y ∣ ∣ ⇕ f ( y ) ≤ f ( x ) + ∇ f ( x ) T ( y − x ) + L 2 ∣ ∣ y − x ∣ ∣ 2   (1-5) ||\nabla (\mathbf x)-\nabla f(\mathbf y)||\leq L||\mathbf x-\mathbf y||\\ \Updownarrow\\ f(\mathbf y)\leq f(\mathbf x)+\nabla f(\mathbf x)^T(\mathbf y-\mathbf x)+\frac{L}2 ||\mathbf y-\mathbf x||^2 \ \tag{1-5} ∣∣∇(x)f(y)∣∣L∣∣xy∣∣f(y)f(x)+f(x)T(yx)+2L∣∣yx2 (1-5)
L i p s c h i t z Lipschitz Lipschitz连续条件保证了函数不会剧烈变化,它使得函数足够光滑,我们把 L L L称为光滑系数。

强凸函数 ∀ x , y ∈ R n , ∃ μ ∈ R + \forall \mathbf x,\mathbf y \in \Bbb R^n,\exist \mu \in \Bbb R^+ x,yRn,μR+使得
∇ 2 f ( x ) ≻ 0 ⇕ ∇ 2 f ( x ) ⪰ μ I ⇕ f ( y ) ≥ f ( x ) + ∇ f ( x ) T ( y − x ) + μ 2 ∣ ∣ y − x ∣ ∣ 2   (1-6) \nabla ^2f(\mathbf x) \succ 0\\ \Updownarrow\\ \nabla ^2f(\mathbf x) \succeq \mu I\\ \Updownarrow\\ f(\mathbf y)\geq f(\mathbf x)+\nabla f(\mathbf x)^T(\mathbf y-\mathbf x)+\frac{\mu}2 ||\mathbf y-\mathbf x||^2\ \tag{1-6} 2f(x)02f(x)μIf(y)f(x)+f(x)T(yx)+2μ∣∣yx2 (1-6)
也就是说,目标函数需要比某个二次函数更凸,强凸函数保证目标函数一定存在一个全局极小值,我们称 μ \mu μ为强凸系数。

假设函数是 L i p s c h i t z Lipschitz Lipschitz连续,设光滑系数为 L L L,学习率 η ≤ 1 L \eta \leq\frac{1}{L} ηL1。令 y = x k + 1 , x = x k , x k + 1 = x k − η ∇ f ( x k ) \mathbf y = \mathbf x_{k+1},\mathbf x=\mathbf x_k,\mathbf x_{k+1}=\mathbf x_{k}-\eta\nabla f(\mathbf x_{k}) y=xk+1,x=xk,xk+1=xkηf(xk),带入式(1-5)中得
f ( x k + 1 ) ≤ f ( x k ) − 1 2 L ∣ ∣ ∇ f ( x k ) ∣ ∣ 2   (1-7) f(\mathbf x_{k+1})\leq f(\mathbf x_k)-\frac{1}{2L}||\nabla f(\mathbf x_k)||^2\ \tag{1-7} f(xk+1)f(xk)2L1∣∣∇f(xk)2 (1-7)
定义 x ∗ \mathbf x^* x为全局最优点。我们想知道 f ( x k ) f(\mathbf x_k) f(xk)以什么样的速度接近 f ( x ∗ ) f(\mathbf x^*) f(x)

对式(1-7)两边同时减去 f ( x ∗ ) f(\mathbf x^*) f(x)
f ( x k + 1 ) − f ( x ∗ ) ≤ f ( x k ) − f ( x ∗ ) − 1 2 L ∣ ∣ ∇ f ( x k ) ∣ ∣ 2 (1-8) f(\mathbf x_{k+1})-f(\mathbf x^*)\leq f(\mathbf x_k)-f(\mathbf x^*)-\frac{1}{2L}||\nabla f(\mathbf x_k)||^2\tag{1-8} f(xk+1)f(x)f(xk)f(x)2L1∣∣∇f(xk)2(1-8)
y = x ∗ , x = x k \mathbf y = \mathbf x^*,\mathbf x =\mathbf x_k y=x,x=xk,代入(1-6)中可得
f ( x ∗ ) ≥ f ( x k ) + ∇ f ( x k ) T ( x ∗ − x k ) + μ 2 ∣ ∣ x ∗ − x k ∣ ∣ 2 ⏟ 记为新的函数 G ( x ∗ ) \begin{aligned} f(\mathbf x^*)&\geq \underbrace{f(\mathbf x_k)+\nabla f(\mathbf x_k)^T(\mathbf x^*-\mathbf x_k)+\frac{\mu}2 ||\mathbf x^*-\mathbf x_k||^2}_{记为新的函数G(\mathbf x^*)}\\ & \end{aligned} f(x)记为新的函数G(x) f(xk)+f(xk)T(xxk)+2μ∣∣xxk2
其中, G ( x ∗ ) G(\mathbf x^*) G(x)是一个关于 x ∗ \mathbf x^* x的凸函数,对其求导 ∇ x ∗ G ( x ∗ ) = 0 \nabla _{\mathbf x^*}G(\mathbf x^*)=0 xG(x)=0可计算出 G ( x ∗ ) G(\mathbf x^*) G(x)的最小值。
x ∗ = x k − 1 μ ∇ f ( x k ) ⇓ G ( x ∗ ) ≥ f ( x k ) − 1 2 μ ∣ ∣ ∇ f ( x k ) ∣ ∣ 2 ⇓ f ( x ∗ ) ≥ f ( x k ) − 1 2 μ ∣ ∣ ∇ f ( x k ) ∣ ∣ 2 ⇓ − ∣ ∣ ∇ f ( x ) ∣ ∣ 2 ≤ − 2 μ ( f ( x k ) − f ( x ∗ ) ) (1-9) \mathbf x^*=\mathbf x_k-\frac{1}{\mu}\nabla f(\mathbf x_k)\\ \Downarrow\\ G(\mathbf x^*) \geq f(\mathbf x_k)-\frac{1}{2\mu}||\nabla f(\mathbf x_k)||^2\\ \Downarrow\\ f(\mathbf x^*)\geq f(\mathbf x_k)-\frac{1}{2\mu}||\nabla f(\mathbf x_k)||^2\\ \Downarrow\\ -||\nabla f(\mathbf x)||^2\leq -2\mu(f(\mathbf x_k)-f(\mathbf x^*)) \tag{1-9} x=xkμ1f(xk)G(x)f(xk)2μ1∣∣∇f(xk)2f(x)f(xk)2μ1∣∣∇f(xk)2∣∣∇f(x)22μ(f(xk)f(x))(1-9)
带入(1-8)中可得
f ( x k + 1 ) − f ( x ∗ ) ≤ f ( x k ) − f ( x ∗ ) − 1 2 L ∣ ∣ ∇ f ( x k ) ∣ ∣ 2 ≤ f ( x k ) − f ( x ∗ ) − μ L ( f ( x k ) − f ( x ∗ ) ) = ( 1 − μ L ) ( f ( x k ) − f ( x ∗ ) ) \begin{aligned} f(\mathbf x_{k+1})-f(\mathbf x^*)&\leq f(\mathbf x_k)-f(\mathbf x^*)-\frac{1}{2L}||\nabla f(\mathbf x_k)||^2\\ &\leq f(\mathbf x_k)-f(\mathbf x^*)-\frac{\mu}{L}( f(\mathbf x_k)-f(\mathbf x^*)) \\ &=(1-\frac{\mu}{L})( f(\mathbf x_k)-f(\mathbf x^*)) \end{aligned} f(xk+1)f(x)f(xk)f(x)2L1∣∣∇f(xk)2f(xk)f(x)Lμ(f(xk)f(x))=(1Lμ)(f(xk)f(x))
因此在限制步长 η ≤ 1 L \eta\leq\frac{1}{L} ηL1 ,函数满足强凸以及 L i p s c h i t z Lipschitz Lipschitz连续,收敛速率为
f ( x k + 1 ) − f ( x ∗ ) f ( x k ) − f ( x ∗ ) ≤ 1 − μ L (1-10) \frac{f(\mathbf x_{k+1})-f(\mathbf x^*)}{ f(\mathbf x_k)-f(\mathbf x^*)}\leq 1-\frac{\mu}{L}\tag{1-10} f(xk)f(x)f(xk+1)f(x)1Lμ(1-10)
梯度下降法作用在强凸和光滑函数上的收敛速率是线性的。

(在此之后的 B G D , S G D , A d a G r a d , R M S P r o p , A d a m BGD,SGD,AdaGrad,RMSProp,Adam BGD,SGD,AdaGrad,RMSProp,Adam都是梯度下降法的衍生版本,虽然他们都对梯度下降进行了优化,但他们都只利用了函数的一阶信息,并未直接利用函数的二阶信息—— H e s s i a n Hessian Hessian矩阵)

三.牛顿法(二阶优化算法)

将目标函数利用到二阶可以获得关于函数的曲率信息,获得更精准的下降方向。记 H ( x ) = ∇ 2 f ( x ) H(\mathbf x)=\nabla^2 f(\mathbf x) H(x)=2f(x), 定义 ∣ ⋅ ∣ H ( x ) |\cdot|_{H(\mathbf x)} H(x)范数
∣ x ∣ H ( x ) = x T H ( x ) x   |\mathbf x|_{H(\mathbf x)}=\mathbf x^TH(\mathbf x)\mathbf x \ xH(x)=xTH(x)x 
约束问题重写为
m i n m i z e     f ( x + Δ x )   s . t           Δ x T H ( x ) Δ x ≤ c lim ⁡ c → 0 (1-11) \begin{aligned} \mathrm{minmize} \ \ \ &f(\mathbf x+\Delta \mathbf x) \\\ s.t\ \ \ \ \ \ \ \ \ &\mathbf \Delta x^TH(\mathbf x)\mathbf \Delta x \leq c\\ &\lim c \rightarrow 0 \end{aligned} \tag{1-11} minmize    s.t         f(x+Δx)ΔxTH(x)Δxclimc0(1-11)
需要注意的是,如果 H e s s i a n Hessian Hessian矩阵负定,则以上约束问题无解(不存在极小值只有极大值)

构建拉格朗日函数为
L = f ( x + Δ x ) + λ ( Δ x T H ( x ) Δ x − c ) L=f(\mathbf x+\Delta \mathbf x)+\lambda (\mathbf \Delta x^TH(\mathbf x)\mathbf \Delta x -c) L=f(x+Δx)+λ(ΔxTH(x)Δxc)
∇ Δ x L = 0 \nabla _{\Delta\mathbf x}L=0 ΔxL=0得出
Δ x = − H ( x ) − 1 λ ∇ f ( x ) \Delta \mathbf x =\frac{-H(\mathbf x)^{-1}}{\lambda}\nabla f(\mathbf x) Δx=λH(x)1f(x)

所以最优下降方向可定义为

− ( H ( x ) ) − 1 ∇ f ( x ) (1-12) -(H(\mathbf x))^{-1}\nabla f(\mathbf x) \tag{1-12} (H(x))1f(x)(1-12)

迭代公式

x k + 1 = x k − η H ( x ) − 1 ∇ f ( x k ) (1-13) \mathbf x_{k+1}=\mathbf x_{k}-\eta H(\mathbf x)^{-1}\nabla f(\mathbf x_{k})\tag{1-13} xk+1=xkηH(x)1f(xk)(1-13)
因此牛顿法可以认为是 ∣ ⋅ ∣ H ( x ) |\cdot|_{H(\mathbf x)} H(x)范数下的最优化算法

牛顿法在凸函数上有着更快的收敛速度,但是计算存储以及求 H e a a i a n Heaaian Heaaian矩阵的逆有着高昂的计算复杂度,并且要求 H e s s i a n Hessian Hessian矩阵正定,更严重的是在非二次误差曲面上该算法可能不收敛

四.牛顿法收敛速度分析

可以证明牛顿法在条件足够好的情况下,能够以极快的速度收敛到最优点(二次收敛)。

我们假设目标函数的二阶导满足 L i p s c h i t z Lipschitz Lipschitz 连续,即 ∃ L ≥ 0 \exist L\geq 0 L0使得
∣ ∣ ∇ 2 f ( x ) − ∇ 2 f ( y ) ∣ ∣ ≤ L ∣ ∣ x − y ∣ ∣ (1-14) ||\nabla ^2f(\mathbf x)-\nabla ^2f(\mathbf y)||\leq L||\mathbf x-\mathbf y||\tag{1-14} ∣∣2f(x)2f(y)∣∣L∣∣xy∣∣(1-14)
并且目标函数是强凸的
∣ ∣ ∇ 2 f ( x ) ∣ ∣ ≥ μ ⇕ ∣ ∣ ∇ 2 f ( x ) − 1 ∣ ∣ ≤ 1 μ (1-15) ||\nabla^2 f(\mathbf x)||\geq \mu\tag{1-15}\\ \Updownarrow\\ ||\nabla^2 f(\mathbf x)^{-1}||\leq \frac{1}{\mu} ∣∣2f(x)∣∣μ∣∣2f(x)1∣∣μ1(1-15)
给定步长为1,在(1-13)左右同时减去 x ∗ \mathbf x^* x,可得
∣ ∣ x k + 1 − x ∗ ∣ ∣ = ∣ ∣ x k − x ∗ − H ( x ) − 1 ∇ f ( x k ) ∣ ∣ = ∣ ∣ H ( x ) − 1 ( H ( x ) ( x k − x ∗ ) − ( ∇ f ( x k ) − ∇ f ( x ∗ ) ) ) ∣ ∣          ( 因为 ∇ f ( x ∗ = 0 ) ) ≤ ∣ ∣ H ( x ) − 1 ∣ ∣ ∗ ∣ ∣ H ( x ) ( x k − x ∗ ) − ( ∇ f ( x k ) − ∇ f ( x ∗ ) ) ∣ ∣ = ∣ ∣ H ( x ) − 1 ∣ ∣ ∗ ∣ ∣ ∫ 0 1 ( H ( x k ) − H ( x k + t ( x ∗ − x k ) ) ) ( x ∗ − x k ) d t ∣ ∣ ≤ ∣ ∣ H ( x ) − 1 ∣ ∣ ∗ ∫ 0 1 ∣ ∣ H ( x k ) − H ( x k + t ( x ∗ − x k ) ) ∣ ∣ ∗ ∣ ∣ x ∗ − x k ∣ ∣ d t ≤ ∣ ∣ H ( x ) − 1 ∣ ∣ ∗ ∣ ∣ x ∗ − x k ∣ ∣ 2 ∫ 0 1 L t d t        ( L i p s c h i t z 连续 ) = 1 2 L ∣ ∣ H ( x ) − 1 ∣ ∣ ∗ ∣ ∣ x ∗ − x k ∣ ∣ 2 ≤ L 2 μ ∣ ∣ x ∗ − x k ∣ ∣ 2         ( 强凸性 ) \begin{aligned} ||\mathbf x_{k+1}-\mathbf x^*||&=||\mathbf x_{k}-\mathbf x^*-H(\mathbf x)^{-1}\nabla f(\mathbf x_{k})||\\ &=||H(\mathbf x)^{-1}(H(\mathbf x)(\mathbf x_k-\mathbf x^*)-(\nabla f(\mathbf x_k)-\nabla f(x^*)))||\ \ \ \ \ \ \ \ (因为\nabla f(\mathbf x^*=0))\\ &\leq ||H(\mathbf x)^{-1}||*||H(\mathbf x)(\mathbf x_k-\mathbf x^*)-(\nabla f(\mathbf x_k)-\nabla f(x^*))|| \\ &=||H(\mathbf x)^{-1}||*||\int^1_0(H(\mathbf x_k)-H(\mathbf x_k+t(\mathbf x^*-\mathbf x_k)))(\mathbf x^*-\mathbf x_k)\mathrm dt||\\ &\leq||H(\mathbf x)^{-1}||*\int^1_0||H(\mathbf x_k)-H(\mathbf x_k+t(\mathbf x^*-\mathbf x_k))||*||\mathbf x^*-\mathbf x_k||\mathrm dt\\ &\leq ||H(\mathbf x)^{-1}||*||\mathbf x^*-\mathbf x_k||^2\int^1_0Lt\mathrm dt\ \ \ \ \ \ (Lipschitz连续)\\ &=\frac{1}{2}L||H(\mathbf x)^{-1}||*||\mathbf x^*-\mathbf x_k||^2\\ &\leq \frac{L}{2\mu}||\mathbf x^*-\mathbf x_k||^2\ \ \ \ \ \ \ (强凸性) \end{aligned} ∣∣xk+1x∣∣=∣∣xkxH(x)1f(xk)∣∣=∣∣H(x)1(H(x)(xkx)(f(xk)f(x)))∣∣        (因为f(x=0))∣∣H(x)1∣∣∣∣H(x)(xkx)(f(xk)f(x))∣∣=∣∣H(x)1∣∣∣∣01(H(xk)H(xk+t(xxk)))(xxk)dt∣∣∣∣H(x)1∣∣01∣∣H(xk)H(xk+t(xxk))∣∣∣∣xxk∣∣dt∣∣H(x)1∣∣∣∣xxk201Ltdt      (Lipschitz连续)=21L∣∣H(x)1∣∣∣∣xxk22μL∣∣xxk2       (强凸性)
由此我们证明了牛顿法的收敛速度是超线性的二次收敛。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值