<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>拟牛顿法 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/%E6%8B%9F%E7%89%9B%E9%A1%BF%E6%B3%95/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 27 Apr 2020 17:26:37 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创]拟牛顿法/Quasi-Newton，DFP算法/Davidon-Fletcher-Powell，及BFGS算法/Broyden-Fletcher-Goldfarb-Shanno</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e6%8b%9f%e7%89%9b%e9%a1%bf%e6%b3%95quasi-newton%ef%bc%8cdfp%e7%ae%97%e6%b3%95davidon-fletcher-powell%ef%bc%8c%e5%8f%8abfgs%e7%ae%97%e6%b3%95broyden-fletcher-goldfarb-shanno/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e6%8b%9f%e7%89%9b%e9%a1%bf%e6%b3%95quasi-newton%ef%bc%8cdfp%e7%ae%97%e6%b3%95davidon-fletcher-powell%ef%bc%8c%e5%8f%8abfgs%e7%ae%97%e6%b3%95broyden-fletcher-goldfarb-shanno/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 14 Jun 2011 17:44:56 +0000</pubDate>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[拟牛顿法]]></category>
		<category><![CDATA[最优化]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=2780</guid>

					<description><![CDATA[<p>
	&#160;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在最优化领域，有几个你绝对不能忽略的关键词：拟牛顿、DFP、BFGS。名字很怪，但是非常著名。下面会依次地说明它们分别&#8220;是什么&#8221;，&#8220;有什么用&#8221; 以及 &#8220;怎么来的&#8221;。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px; "><font class="Apple-style-span">但是在进入正文之前，还是要先提到一个概念上的区别，否则将影响大家的理解：其实DFP算法、BFGS算法都属于拟牛顿法，即，DFP、BFGS都分别是一种拟牛顿法。</font></span></span><br />
	<span id="more-2780"></span></p>
<p>
	<span style="font-size: 14px;">先从拟牛顿法（Quasi-Newton）说起。这个怪怪的名词其实很形象：这是一种&#8221;模拟&#8220;的牛顿法。那么，它模拟了牛顿法的哪一部分呢？答：模拟的就是牛顿法中的搜索方向（可以叫作&#8220;牛顿方向&#8221;）的生成方式。</span><br />
	<!--more--></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">牛顿法是什么？本文是基于你已经知道牛顿法的原理的假设，如果你不清楚，那么可以看我<a href="http://www.codelast.com/?p=2573" target="_blank" rel="noopener noreferrer">这篇文章</a>，里面非常简单而又清晰地描述了牛顿法的原理。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">了解了牛顿法的原理，我们就知道了：在每一次要得到新的搜索方向的时候，都需要计算Hesse矩阵（二阶导数矩阵）。在自变量维数非常大的时候，这个计算工作是非常耗时的，因此，拟牛顿法的诞生就有意义了：它采用了一定的方法来构造与Hesse矩阵相似的正定矩阵，而这个构造方法计算量比牛顿法小。这就是对它&#8220;有什么用&#8221;的回答了。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color:#f00;"><span style="font-size:20px;">（1）DFP算法</span></span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">下面，就从DFP算法来看看&#8220;拟牛顿&#8221;是如何实现的（DFP算法是以Davidon、Fletcher、Powell三位牛人的名字的首字母命名的）。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">前面说了，Hesse矩阵在拟牛顿法中是不计算的，拟牛顿法是构造与Hesse矩阵相似的正定矩阵，这个构造方法，使用了<span style="color:#006400;">目标函数的梯度（一阶导数）信息和两个点的&#8220;位移&#8221;（X<sub>k</sub>-X<sub>k-1</sub>）</span>来实现。有人会说，<span style="color:#b22222;">是不是用Hesse矩阵的近似矩阵来代替Hesse矩阵，会导致求解效果变差呢</span>？事实上，效果反而</span>通常会变好。有人又会问为什么？那么就简要地说一下&#8212;&#8212;</span></p>
<p>
	<span style="font-family:微软雅黑;">由<a href="http://www.codelast.com/?p=2573" target="_blank" rel="noopener noreferrer">牛顿法的原理</a>可知如下几个等式：</span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img decoding="async" alt="newton" height="92" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_00.png" width="467" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">若最后一个等式子的最左边 &#60; 0，即<img decoding="async" alt="" height="22" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_0.png" width="101" />，就是直观概念上的&#8220;沿方向d上，目标函数值下降&#8221;的表达。而在逐步寻找最优解的过程中，我们是要求目标函数值下降的，因此，应该有-(X-X<sub>i</sub>)A(X-X<sub>i</sub>) &#60; 0，也即&#160;</span>(X-X<sub>i</sub>)A(X-X<sub>i</sub>) &#62; 0。<span style="font-size:14px;">这表明矩阵A是<a href="http://www.codelast.com/?page_id=963" target="_blank" rel="noopener noreferrer">正定</a>的。而在远离极小值点处，Hesse矩阵一般不能保证正定，使得目标函数值不降反升。而拟牛顿法可以使目标函数值沿下降方向走下去，并且到了最后，在极小值点附近，可使构造出来的矩阵与Hesse矩阵&#8220;很像&#8221;了，这样，拟牛顿法也会具有牛顿法的二阶收敛性。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); font-size: 14px; line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b%e6%8b%9f%e7%89%9b%e9%a1%bf%e6%b3%95quasi-newton%ef%bc%8cdfp%e7%ae%97%e6%b3%95davidon-fletcher-powell%ef%bc%8c%e5%8f%8abfgs%e7%ae%97%e6%b3%95broyden-fletcher-goldfarb-shanno/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	&nbsp;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在最优化领域，有几个你绝对不能忽略的关键词：拟牛顿、DFP、BFGS。名字很怪，但是非常著名。下面会依次地说明它们分别&ldquo;是什么&rdquo;，&ldquo;有什么用&rdquo; 以及 &ldquo;怎么来的&rdquo;。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px; "><font class="Apple-style-span">但是在进入正文之前，还是要先提到一个概念上的区别，否则将影响大家的理解：其实DFP算法、BFGS算法都属于拟牛顿法，即，DFP、BFGS都分别是一种拟牛顿法。</font></span></span><br />
	<span id="more-2780"></span></p>
<p>
	<span style="font-size: 14px;">先从拟牛顿法（Quasi-Newton）说起。这个怪怪的名词其实很形象：这是一种&rdquo;模拟&ldquo;的牛顿法。那么，它模拟了牛顿法的哪一部分呢？答：模拟的就是牛顿法中的搜索方向（可以叫作&ldquo;牛顿方向&rdquo;）的生成方式。</span><br />
	<!--more--></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">牛顿法是什么？本文是基于你已经知道牛顿法的原理的假设，如果你不清楚，那么可以看我<a href="http://www.codelast.com/?p=2573" target="_blank" rel="noopener noreferrer">这篇文章</a>，里面非常简单而又清晰地描述了牛顿法的原理。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">了解了牛顿法的原理，我们就知道了：在每一次要得到新的搜索方向的时候，都需要计算Hesse矩阵（二阶导数矩阵）。在自变量维数非常大的时候，这个计算工作是非常耗时的，因此，拟牛顿法的诞生就有意义了：它采用了一定的方法来构造与Hesse矩阵相似的正定矩阵，而这个构造方法计算量比牛顿法小。这就是对它&ldquo;有什么用&rdquo;的回答了。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color:#f00;"><span style="font-size:20px;">（1）DFP算法</span></span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">下面，就从DFP算法来看看&ldquo;拟牛顿&rdquo;是如何实现的（DFP算法是以Davidon、Fletcher、Powell三位牛人的名字的首字母命名的）。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">前面说了，Hesse矩阵在拟牛顿法中是不计算的，拟牛顿法是构造与Hesse矩阵相似的正定矩阵，这个构造方法，使用了<span style="color:#006400;">目标函数的梯度（一阶导数）信息和两个点的&ldquo;位移&rdquo;（X<sub>k</sub>-X<sub>k-1</sub>）</span>来实现。有人会说，<span style="color:#b22222;">是不是用Hesse矩阵的近似矩阵来代替Hesse矩阵，会导致求解效果变差呢</span>？事实上，效果反而</span>通常会变好。有人又会问为什么？那么就简要地说一下&mdash;&mdash;</span></p>
<p>
	<span style="font-family:微软雅黑;">由<a href="http://www.codelast.com/?p=2573" target="_blank" rel="noopener noreferrer">牛顿法的原理</a>可知如下几个等式：</span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="newton" height="92" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_00.png" width="467" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">若最后一个等式子的最左边 &lt; 0，即<img loading="lazy" decoding="async" alt="" height="22" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_0.png" width="101" />，就是直观概念上的&ldquo;沿方向d上，目标函数值下降&rdquo;的表达。而在逐步寻找最优解的过程中，我们是要求目标函数值下降的，因此，应该有-(X-X<sub>i</sub>)A(X-X<sub>i</sub>) &lt; 0，也即&nbsp;</span>(X-X<sub>i</sub>)A(X-X<sub>i</sub>) &gt; 0。<span style="font-size:14px;">这表明矩阵A是<a href="http://www.codelast.com/?page_id=963" target="_blank" rel="noopener noreferrer">正定</a>的。而在远离极小值点处，Hesse矩阵一般不能保证正定，使得目标函数值不降反升。而拟牛顿法可以使目标函数值沿下降方向走下去，并且到了最后，在极小值点附近，可使构造出来的矩阵与Hesse矩阵&ldquo;很像&rdquo;了，这样，拟牛顿法也会具有牛顿法的二阶收敛性。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); font-size: 14px; line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">由于涉及到Hesse矩阵（二阶导数矩阵），我们当然要从目标函数 f(X) 的泰勒展开式说开去。与最优化理论中的很多问题一样，在这里，我们依然要假设目标函数可以用二次函数进行近似（</span><span style="color:#b22222;">实际上很多函数都可以用二次函数很好地近似</span>）：</span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="taylor expansion of f(X)" height="83" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_01.png" width="477" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">忽略高阶无穷小部分，只看前面的3项，其中A为目标函数的Hesse矩阵（二阶导数矩阵）。此式两边对X求导得：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="" height="30" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_02.png" width="374" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">于是，当 X=X<sub>i</sub> 时，将[2]式两边均左乘(A<sub>i+1</sub>)<sup>-1</sup>，有：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="" height="102" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_03.png" width="407" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">上式左右两边近似相等，但如果我们把它换成等号，并且用另一个矩阵H来代替上式中的A<sup>-1</sup>，则得到：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="quasi-newton function" height="34" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_04.png" width="384" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); font-size: 14px; line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">这个方程，就是拟牛顿方程，其中的矩阵H，就是Hesse矩阵的逆矩阵的一个近似矩阵。但是，从初始的H<sub>0</sub>开始，如何得到每一步迭代过程中需要的H<sub>1</sub>，H<sub>2</sub>，&hellip;&hellip;呢？在迭代过程中生成的矩阵序列H<sub>0</sub>，H<sub>1</sub>，H<sub>2</sub>，&hellip;&hellip;中，每一个矩阵H<sub>i+1</sub>，都是由前一个矩阵H<sub>i</sub>修正得到的，这个修正方法有很多种，这里只说DFP算法的修正方法。</span>设：</span></p>
<p style="text-align: center; color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="matrix H" height="34" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_05.png" style="cursor: default; " width="176" /></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">然后又有问题：矩阵E怎么求？再设：</span></span></p>
<p style="text-align: center; color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="matrix E" height="34" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_06.png" style="cursor: default; " width="217" /></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">其中，m和n均为实数，v和w均为N维向量。将[6]代入[5]式，再将[5]式代入[4]式，可得：</span></span></p>
<p style="text-align: center; color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="" height="294" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_07.png" style="cursor: default; " width="532" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); font-size: 14px; line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">[8]式与[7]式完全相同，只不过用简化的记号重写了一下。如果求出了m，n，v，w，就可以知道[6]式怎么求，从而进一步知道[5]式怎么求，从而我们的问题就彻底解决了。符合[7]这个方程的v，w可能有很多，但是我们有没有可能找到v，w的一个&ldquo;特例&rdquo;，使之符合这个等式呢？仔细观察一下，是可以找到的：[7]式的右边两个向量相减的结果，是一个n&times;1的向量，因此，等式左边的计算结果当然也是一个n&times;1的向量（每一项都是一个n&times;1的向量），所以我们把[7]式写成了[8]式的样子，可以看到，其中的第二、第三项中的括号里的向量的点积均为实数，这里，可以使第一个括号中的mv<sup>T</sup>q<sub>i</sub>值为1，使第二个括号中的nw<sup>T</sup>q<sub>i</sub>值为-1，这样的话，v只要取s<sub>i</sub>，w只要取H<sub>i</sub>q<sub>i</sub>，就可以使[8]式成立了。的确，这种带有一点猜测性质的做法，确实可以让我们找到一组适合的m，n，v，w值。</span></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">所以，我们得到的m，n，v，w值如下：</span></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="m,n,v,w" height="151" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_08.png" width="363" /></span></p>
<p style="color: rgb(0, 0, 0); ">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><font class="Apple-style-span">现在我们几乎大功告成了：将[8]~[11]代入[6]式，然后再将[6]代入[5]式，就得到了Hesse矩阵的逆矩阵的近似阵H的计算方法：</font></span></span></p>
<p style="color: rgb(0, 0, 0); text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="function to calculate H" height="195" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_09.png" style="cursor: default; " width="512" /></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在上面的推导过程中，有人可能觉得有点无厘头：为什么[6]式要那样假设，是怎么想到的？我能给出的答案是：这一点我也没想明白。如果你知道，请告诉我，非常感谢。某些书上经常写类似于&ldquo;很显然，XXX&rdquo;之类的话，从一个定理直接得出了一个让人摸不着头脑的结论，而作为我这样比较笨的人来说，我觉得写书的很多专家们认为&ldquo;很显然&rdquo;的东西一点也不&ldquo;显然&rdquo;，甚至于有时候，我觉得那就像凤姐突然变成了范冰冰一样&mdash;&mdash;一下子变出来了一个漂亮的结论，难以相信。所以这也是为什么我花费了很多时间，来把一些&ldquo;很显然&rdquo;的东西记下来，写明白的原因了。对于大多数牛人，他们需要的当然不是这种思维跨度这么小的文章，而是那种从地球可以一下子飞到火星的文章。所以，我写的东西不适合于水平高的人看，我只期望能帮助一小部分人就知足了。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); font-size: 14px; line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">说到这里，那么到底什么是DFP算法呢？上面的矩阵H的计算方法就是其核心，下面再用简单的几句话描述一下DFP算法的流程：</span></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">已知初始正定矩阵H<sub>0</sub>，从一个初始点开始（迭代），用式子&nbsp;<img loading="lazy" decoding="async" alt="function to calculate search direction in DFP" height="24" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_10.png" width="136" />&nbsp;来计算出下一个搜索方向，并在该方向上求出可使目标函数极小化的步长&alpha;，然后用这个步长，将当前点挪到下一个点上，并检测是否达到了程序中止的条件，如果没有达到，则用上面所说的[13]式的方法计算出下一个修正矩阵H，并计算下一个搜索方向&hellip;&hellip;周而复始，直到达到程序中止条件。</span></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">有人会说，上面那些乱七八糟的都是搞什么啊，猜来猜去的就折腾出了一个公式，然后就确定这公式能用了？就不怕它在迭代的时候根本无法寻找到目标函数的极小值？正因为有这些疑问，所以在这里，还要提及一个<span style="color:#f00;">非常重要的问题</span>：我们通过带有猜测性质的做法，得到了矩阵H的计算公式，但是，这个修正过的矩阵，能否保持<span style="color:#00f;">正定</span>呢？前面已经说了，<span style="color:#00f;">矩阵H正定是使目标函数值下降的条件，</span>所以，它保持正定性很重要。<span style="color:#800080;">可以证明</span>，矩阵H保持正定的<span style="color:#006400;">充分必要条件</span>是：</span></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="condition to keep matrix H positive definite" height="34" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_12.png" style="cursor: default; " width="414" /></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">并且，在迭代过程中，<span style="color:#b22222;">这个条件也是容易满足的</span>。此结论的证明并不复杂，但是为了不影响本文的主旨，这里就没有必要写出来了。总之，我觉得作为一个最优化的学习者来说，首先要关注的是不是这些细节问题，而是先假设这些算法都适用，然后等积累到一定程度了，再去想&ldquo;为什么能适用&rdquo;的问题。</span></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	&nbsp;</p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="color:#f00;"><span style="font-size:14px;"><span style="font-size:20px;">（2）BFGS算法</span></span></span></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size: 14px; "><font class="Apple-style-span">在上面的DFP算法的推导中，我们得到了矩阵H的计算公式，而BFGS算法和它有点像，但是比它形式上复杂一点。尽管它更复杂，但是在BFGS算法被Broyden，Fletcher，Goldfarb，Shanno四位牛人发明出来到现在的40多年时间里，它仍然被认为是最好的拟牛顿算法。历史总是这样，越往后推移，人们要超越某种技术所需的时间通常就越长。但是我们很幸运地可以站在巨人的肩膀上，从而可以在使用前人已经发明的东西的基础上感叹一声：这玩意太牛了。</font></span></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;"><font class="Apple-style-span">好吧，又扯远了&hellip;&hellip; 回到中心主题，看看在BFGS算法中，与上面的[13]式一样的矩阵H是如何计算的：</font></span></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="matrix H in BFGS" height="315" src="http://www.codelast.com/wp-content/uploads/2011/06/quasi_dfp_bfgs_11.png" style="cursor: default; " width="530" /></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在[14]式中，<span style="color:#b22222;">最后一项（深蓝色的部分）就是BFGS比DFP多出来的东西</span>。其中，w为一个n&times;1的向量。我们看到，由于向量w的表达式太长，所以没有把它直接写在[14]式中，而是单独列在了[15]式里。</span></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">可能[14]式一看就让人头晕，所以先来弱弱地解释一下这个式子的计算结果（如果你觉得好雷人，那么请直接无视）：ww<sup>T</sup>是一个n&times;1的向量与一个1&times;n的向量相乘，结果为一个n&times;n的矩阵，而[14]式中最后一项里，除了ww<sup>T</sup>之外的那一部分是（1&times;n）向量、n&times;n矩阵、n&times;1向量相乘，结果为一实数，因此[14]式最后一项结果为一个n&times;n矩阵，这与[14]式等号左边的矩阵H为n&times;n矩阵一致。这一点没有问题了。</span></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在目标函数为<a href="http://zh.wikipedia.org/wiki/%E4%BA%8C%E6%AC%A1%E5%9E%8B" target="_blank" rel="noopener noreferrer">二次型</a>（&ldquo;在数学中，二次型是一些变量上的二次齐次多项式&rdquo;）时，无论是DFP还是BFGS&mdash;&mdash;也就是说，无论[14]式中有没有最后一项&mdash;&mdash;它们均可以使矩阵H在n步之内收敛于A<sup>-1</sup>。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); font-size: 14px; line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; ">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">延伸阅读：BFGS有一个变种（我不知道这样称呼是否正确），叫作&ldquo;<span style="color:#f00;">Limited-memory BFGS</span>&rdquo;，简称&ldquo;<span style="color:#f00;">L-BFGS</span>&rdquo;或&ldquo;<span style="color:#f00;">LM-BFGS</span>&rdquo;（这里的&ldquo;LM&rdquo;与<a href="http://www.codelast.com/?p=29" target="_blank" rel="noopener noreferrer">Levenberg-Marquard算法</a>没有关系），从它的名字上看，你肯定能猜到，使用L-BFGS算法来编写程序时，它会比BFGS算法占用的内存小。从前面的文章中，我们知道，BFGS在计算过程中要存储一个n&times;n的矩阵，当维数n很大的时候，这个内存占用量会很大&mdash;&mdash;例如，在10万维的情况下，假设矩阵H中的元素以double来存储，那么，内存占用即为100000&times;100000&times;8&divide;1024&divide;1024&divide;1024&asymp;74.5（GB），这太惊人了，一般的服务器几乎无法承受。所以，使用L-BFGS来降低内存使用量在某些情况下是非常有意义的。</span></span></p>
<p style="color: rgb(0, 0, 0); font-size: medium; ">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">关于L-BFGS的英文解释，请点击<a href="http://en.wikipedia.org/wiki/L-BFGS" target="_blank" rel="noopener noreferrer">这个Wiki链接</a>。由于我还没有深入学习L-BFGS，所以没办法在这里详细叙述了。</span></span></p>
<p style="color: rgb(0, 0, 0); font-family: Simsun; font-size: medium; ">
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">（全文完）</span></span><br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e6%8b%9f%e7%89%9b%e9%a1%bf%e6%b3%95quasi-newton%ef%bc%8cdfp%e7%ae%97%e6%b3%95davidon-fletcher-powell%ef%bc%8c%e5%8f%8abfgs%e7%ae%97%e6%b3%95broyden-fletcher-goldfarb-shanno/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
	</channel>
</rss>
