<?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/%E5%85%B1%E8%BD%AD%E6%A2%AF%E5%BA%A6%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:12 +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>[原创]最速下降法/steepest descent，牛顿法/newton，共轭方向法/conjugate direction，共轭梯度法/conjugate gradient 及其他</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e6%9c%80%e9%80%9f%e4%b8%8b%e9%99%8d%e6%b3%95%ef%bc%8c%e7%89%9b%e9%a1%bf%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%96%b9%e5%90%91%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%a2%af%e5%ba%a6/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e6%9c%80%e9%80%9f%e4%b8%8b%e9%99%8d%e6%b3%95%ef%bc%8c%e7%89%9b%e9%a1%bf%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%96%b9%e5%90%91%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%a2%af%e5%ba%a6/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 29 May 2011 19:52:25 +0000</pubDate>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[steepest descent]]></category>
		<category><![CDATA[共轭方向法]]></category>
		<category><![CDATA[共轭梯度法]]></category>
		<category><![CDATA[最优化]]></category>
		<category><![CDATA[最速下降法]]></category>
		<category><![CDATA[牛顿法]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=2573</guid>

					<description><![CDATA[<p>
	&#160;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在最优化的领域中，这&#8220;法&#8221;那&#8220;法&#8221;无穷多，而且还&#8220;长得像&#8221;&#8212;&#8212;名字相似的多，有时让人觉得很迷惑。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在自变量为一维的情况下，也就是自变量可以视为一个标量，此时，一个实数就可以代表它了，这个时候，如果要改变自变量的值，则其要么减小，要么增加，也就是&#8220;非左即右&#8220;，所以，说到&#8220;自变量在某个方向上移动&#8221;这个概念的时候，它并不是十分明显；而在自变量为n（n&#8805;2）维的情况下，这个概念就有用了起来：假设自变量X为3维的，即每一个X是（x<sub>1</sub>, x<sub>2</sub></span>, x<sub>3</sub><span style="font-size:14px;">）这样的一个点，其中x<sub>1</sub>，x<sub>2</sub>和x<sub>3</sub>分别是一个实数，即标量。那么，如果要改变X，即将一个点移动到另一个点，你怎么移动？可以选择的方法太多了，例如，我们可以令x<sub>1</sub>，x<sub>2</sub>不变，仅使x<sub>3</sub>改变，也可以令x<sub>1</sub>，x<sub>3</sub>不变，仅使x<sub>2</sub>改变，等等。这些做法也就使得我们有了&#8221;方向&#8220;的概念，因为在3维空间中，一个点移动到另一个点，并不是像一维情况下那样&#8220;非左即右&#8221;的，而是有&#8220;方向&#8221;的。在这样的情况下，找到一个合适的&#8221;方向&#8220;，使得从一个点移动到另一个点的时候，函数值的改变最符合我们预定的要求（例如，函数值要减小到什么程度），就变得十分有必要了。</span></span><br />
	<span id="more-2573"></span></p>
<p>
	<span style="font-size: 14px; color: rgb(255, 255, 255); line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" style="font-size: 14px; " target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></p>
<p>
	<span style="font-size: 14px; ">前奏已经结束，下面进入正题。</span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:20px;"><span style="color:#f00;">【</span><span style="color:#00f;">1</span><span style="color:#f00;">】</span><span style="color:#00f;">最速下降法（或：梯度法）</span></span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;"><span style="color:#0000ff;">加注：我又写了一篇关于最速下降法的文章，更详细，请看<a href="http://www.codelast.com/?p=8006" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">这里</span></a>。</span></span></span></p>
<p>	很形象，也许你的脑子里一闪而过的，就是：取可以让目标函数值最快速&#8220;下降&#8221;的方法？差不多是这么回事。严谨地说：<span style="color:#f00;">以负梯度方向作为极小化方法的下降方向，这种方法就是最速下降法</span>。</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">为什么是<span style="color:#b22222;">负梯度</span>方向使目标函数值下降最快？以前我也只是死记硬背，背出来的东西虽然有用，终究还是令人糊涂的。所以有必要写出它&#8221;为什么&#8220;的理由：</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">我们正在讨论的是&#8221;n维空间中的一个点移动到另一个点之后，目标函数值的改变情况&#8220;，因此，先直接写出代表最终的目标函数值的数学表达式：</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img decoding="async" alt="dest function value taylor series" height="32" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_1.png" width="382" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img decoding="async" alt="start point" height="27" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_2.png" width="27" />：代表第k个点的自变量（一个向量）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img decoding="async" alt="direction" height="22" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_4.png" width="17" />：单位方向（一个向量），即 &#124;d&#124;=1。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="step" height="18" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_3.png" width="18" />：步长（一个实数）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="gradient" height="31" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_5.png" width="134" />：目标函数在X<sub>k</sub>这一点的梯度（一个向量）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="higher-order infinitesimal" height="22" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_6.png" width="45" />：&#945;的高阶无穷小。</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%9c%80%e9%80%9f%e4%b8%8b%e9%99%8d%e6%b3%95%ef%bc%8c%e7%89%9b%e9%a1%bf%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%96%b9%e5%90%91%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%a2%af%e5%ba%a6/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	&nbsp;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在最优化的领域中，这&ldquo;法&rdquo;那&ldquo;法&rdquo;无穷多，而且还&ldquo;长得像&rdquo;&mdash;&mdash;名字相似的多，有时让人觉得很迷惑。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在自变量为一维的情况下，也就是自变量可以视为一个标量，此时，一个实数就可以代表它了，这个时候，如果要改变自变量的值，则其要么减小，要么增加，也就是&ldquo;非左即右&ldquo;，所以，说到&ldquo;自变量在某个方向上移动&rdquo;这个概念的时候，它并不是十分明显；而在自变量为n（n&ge;2）维的情况下，这个概念就有用了起来：假设自变量X为3维的，即每一个X是（x<sub>1</sub>, x<sub>2</sub></span>, x<sub>3</sub><span style="font-size:14px;">）这样的一个点，其中x<sub>1</sub>，x<sub>2</sub>和x<sub>3</sub>分别是一个实数，即标量。那么，如果要改变X，即将一个点移动到另一个点，你怎么移动？可以选择的方法太多了，例如，我们可以令x<sub>1</sub>，x<sub>2</sub>不变，仅使x<sub>3</sub>改变，也可以令x<sub>1</sub>，x<sub>3</sub>不变，仅使x<sub>2</sub>改变，等等。这些做法也就使得我们有了&rdquo;方向&ldquo;的概念，因为在3维空间中，一个点移动到另一个点，并不是像一维情况下那样&ldquo;非左即右&rdquo;的，而是有&ldquo;方向&rdquo;的。在这样的情况下，找到一个合适的&rdquo;方向&ldquo;，使得从一个点移动到另一个点的时候，函数值的改变最符合我们预定的要求（例如，函数值要减小到什么程度），就变得十分有必要了。</span></span><br />
	<span id="more-2573"></span></p>
<p>
	<span style="font-size: 14px; color: rgb(255, 255, 255); line-height: 20px; text-align: left; background-color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" style="font-size: 14px; " target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a></p>
<p>
	<span style="font-size: 14px; ">前奏已经结束，下面进入正题。</span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:20px;"><span style="color:#f00;">【</span><span style="color:#00f;">1</span><span style="color:#f00;">】</span><span style="color:#00f;">最速下降法（或：梯度法）</span></span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;"><span style="color:#0000ff;">加注：我又写了一篇关于最速下降法的文章，更详细，请看<a href="http://www.codelast.com/?p=8006" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">这里</span></a>。</span></p>
<p>	很形象，也许你的脑子里一闪而过的，就是：取可以让目标函数值最快速&ldquo;下降&rdquo;的方法？差不多是这么回事。严谨地说：<span style="color:#f00;">以负梯度方向作为极小化方法的下降方向，这种方法就是最速下降法</span>。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">为什么是<span style="color:#b22222;">负梯度</span>方向使目标函数值下降最快？以前我也只是死记硬背，背出来的东西虽然有用，终究还是令人糊涂的。所以有必要写出它&rdquo;为什么&ldquo;的理由：</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">我们正在讨论的是&rdquo;n维空间中的一个点移动到另一个点之后，目标函数值的改变情况&ldquo;，因此，先直接写出代表最终的目标函数值的数学表达式：</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="dest function value taylor series" height="32" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_1.png" width="382" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="start point" height="27" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_2.png" width="27" />：代表第k个点的自变量（一个向量）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="direction" height="22" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_4.png" width="17" />：单位方向（一个向量），即 |d|=1。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="step" height="18" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_3.png" width="18" />：步长（一个实数）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="gradient" height="31" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_5.png" width="134" />：目标函数在X<sub>k</sub>这一点的梯度（一个向量）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="higher-order infinitesimal" height="22" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_6.png" width="45" />：&alpha;的高阶无穷小。</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-size:14px;"><span style="font-family:微软雅黑;">显然，这个数学表达式是用泰勒公式展开得到的，样子有点难看，所以对比一下自变量为一维的情况下的泰勒展开式</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="one dimension taylor series" height="34" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_7.png" width="326" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">就知道多维的情况下的泰勒展开式是怎么回事了。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">在[1]式中，高阶无穷小可以忽略，因此，要使[1]式取到最小值，应使<img loading="lazy" decoding="async" alt="gradient multiplied by direction" height="29" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_8.png" width="46" />取到最小&mdash;&mdash;这是两个向量的<span style="color:#b22222;">点积（数量积）</span>，何种情况下其值最小呢？来看两向量<img loading="lazy" decoding="async" alt="vector a and b" height="30" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_9.png" width="40" />的夹角&theta;的余弦是如何定义的：</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="cosθ" height="70" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_10.png" width="133" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">假设向量<img loading="lazy" decoding="async" alt="direction" height="22" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_4.png" style="cursor: default; " width="17" />与负梯度<img loading="lazy" decoding="async" alt="negative gradient" height="25" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_13.png" style="cursor: default; " width="42" />的夹角为&theta;，我们便可求出点积<img loading="lazy" decoding="async" alt="gradient multiplied by direction" height="29" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_8.png" style="cursor: default; " width="46" />的值为：</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="value of gradient multiplied by direction" height="38" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_12.png" width="342" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">可见，&theta;为0时，上式取得最小值。也就是说，<img loading="lazy" decoding="async" alt="direction" height="22" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_4.png" style="cursor: default; " width="17" />取<img loading="lazy" decoding="async" alt="negative gradient" height="25" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_13.png" style="cursor: default; " width="42" />时，目标函数值下降得最快，这就是称负梯度方向为&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;"><span style="color:#800080;">最速下降法的收敛性</span>：对一般的目标函数是整体收敛的（所谓整体收敛，是指不会非要在某些点附近的范围内，才会有好的收敛性）。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;"><span style="color:#800080;">最速下降法的收敛速度</span>：至少是线性收敛的。</span></span></p>
<p>
	&nbsp;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:20px;"><span style="color: rgb(255, 0, 0); ">【</span><span style="color: rgb(0, 0, 255); ">2</span><span style="color: rgb(255, 0, 0); ">】</span><span style="color: rgb(0, 0, 255); ">牛顿法</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">上面的最速下降法只用到了梯度信息，即目标函数的一阶导数信息，而牛顿法则用到了二阶导数信息。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">在<img loading="lazy" decoding="async" alt="start point" height="27" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_2.png" style="cursor: default; " width="27" />点处，对目标函数进行泰勒展开，并只取二阶导数及其之前的几项（更高阶的导数项忽略），得：</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="taylor seires at Xk" height="49" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_14.png" width="480" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="gradient" height="31" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_5.png" style="cursor: default; " width="134" />：目标函数在X<sub>k</sub>这一点的梯度（一个向量）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="Hesse matrix" height="28" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_15.png" width="133" />：目标函数在X<sub>k</sub>这一点的<a href="http://www.codelast.com/?p=2348" target="_blank" rel="noopener noreferrer">Hesse矩阵</a>（二阶导数矩阵），这里假设其是连续的。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">由于极小值点必然是驻点，而驻点是一阶导数为0的点，所以，对 r(X) 这个函数来说，要取到极小值，我们应该分析其一阶导数。对X求一阶导数，并令其等于0：</span></span><br />
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_16.png" style="width: 300px; height: 39px;" /></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">当G<sub>k</sub>的逆矩阵存在，也即G<sub>k</sub>为<a href="http://www.codelast.com/?page_id=963" target="_blank" rel="noopener noreferrer">非奇异矩阵</a>的时候，将上式两边都左乘G<sub>k</sub>的逆矩阵G<sub>k</sub><sup>-1</sup>，得：</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="calculate next point" height="64" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_17.png" width="271" /></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">到了这一步，已经很明显了。这个式子表达了下一点的计算方法：X<sub>k</sub>在方向d上按步长1（1&times;d = d）移动到点X。所以我们知道方向d怎么求了：</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="solve equation to get d" height="70" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_18.png" width="147" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">如果你觉得上式有点奇怪：<span style="color:#b22222;">为什么都得到了d的表达式，还要再弄出一个</span><span style="color:#b22222;">G<sub>k</sub></span><span style="color:#b22222;">d=-</span><span style="color:#b22222;">g<sub>k</sub></span>？那么我说：因为在实际应用中，d并不是通过G<sub>k</sub><sup>-1</sup>与g<sub>k</sub>相乘来计算出的（因为我们并不知道逆矩阵G<sub>k</sub><sup>-1</sup>是什么），而是通过解方程组G<sub>k</sub>d=-g<sub>k</sub>求出的。这个解方程组的过程，其实也就可能是一个求逆矩阵的过程。<span style="color:#800080;">关于解此方程组的方法，可以参考<a href="http://www.codelast.com/?p=1288" target="_blank" rel="noopener noreferrer">这一篇文章</a></span>。关键时刻，概念清晰很重要。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">有人说，那么方程组可能无解呢？没错，方程组可能是奇异的，在这种情况下，就需要用到其他的修正技术，来获取搜索方向了，本文不谈。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(255, 255, 255); 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></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">上面关于牛顿法的各种推导可能让你觉得杂乱无章，但实际上它们就是牛顿法的基本步骤：<span style="color:#006400;">每一步迭代过程中，通过解线性方程组得到搜索方向，然后将自变量移动到下一个点，然后再计算是否符合收敛条件，不符合的话就一直按这个策略（解方程组&rarr;得到搜索方向&rarr;移动点&rarr;检验收敛条件）继续下去</span>。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(128, 0, 128); ">牛顿法的收敛性</span>：对一般问题都不是整体收敛的（只有当初始点充分接近极小点时，才有很好的收敛性）。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(128, 0, 128); ">牛顿法的收敛速度</span>：二阶收敛。因此，它比最速下降法要快。</span></span></p>
<p>
	&nbsp;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:20px;"><span style="color: rgb(255, 0, 0); ">【</span><font class="Apple-style-span" color="#0000FF">3</font><span style="color: rgb(255, 0, 0); ">】</span><span style="color: rgb(0, 0, 255); ">共轭方向法</span></span></span></p>
<p>
	<span style="color: rgb(0, 0, 255); font-family: 微软雅黑; font-size: 14px;">加注：我又写了一篇关于共轭方向法的文章，更详细，请看</span><a href="http://www.codelast.com/?p=8095" style="font-family: 微软雅黑; font-size: 14px;" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这里</span></a><span style="color: rgb(0, 0, 255); font-family: 微软雅黑; font-size: 14px;">。</span><br />
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">上面的方法，前、后两次迭代的方向并没有特别的相关要求，而共轭方向法则有了&mdash;&mdash;它要求新的搜索方向与前面所有的搜索方向是共轭的。由于搜索方向是向量，所以也就是说，这些向量是满足<span style="color:#006400;">共轭条件</span>的：</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="conjugate condition" height="38" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_20.png" width="102" /></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">其中，m&ne;n，d<sub>m</sub>和d<sub>n</sub>分别为两个向量（搜索方向），G为对称正定矩阵。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#800080;">对于&ldquo;共轭&rdquo;，我有一个自己&ldquo;捏造&rdquo;出来的说法，来帮助你记忆它的含义：看到&ldquo;共轭&rdquo;，就想到&ldquo;共遏&rdquo;，即&ldquo;互相遏制&rdquo;，这不，两个向量中间夹着一个矩阵互相发力，结果谁也占不到便宜&mdash;&mdash;积为0。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">共轭方向法也是只利用了目标函数的梯度信息，即一阶导数信息，不用计算Hesse矩阵，使得其计算量比牛顿法小很多。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">但是，怎么在每一步迭代的过程中，都得到若干个两两共轭的搜索方向？<a href="http://www.codelast.com/?p=388" target="_blank" rel="noopener noreferrer">Powell共轭方向集方法</a>是一个选择，它可以构造出若干个两两共轭的方向。不过，它本身也有一些缺陷：在构造共轭方向的过程中，各方向会逐渐变得线性相关，这就达不到&ldquo;共轭&rdquo;的要求了。所以，有很多种对Powell算法进行修正的策略被人们应用到了实际场景中，现在说到Powell方法，应该或多或少都包含了那些修正策略吧（我的感觉）。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;"><span style="color:#b22222;">特别值得一提的是</span>，在共轭方向法中，新搜索方向的确定，是要满足<span style="color:#006400;">&ldquo;下降&rdquo;条件</span>的，即方向与梯度之积&lt;0：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="descent property" height="34" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_19.png" width="95" /></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">是不是意味着目标函数值下降量越大，这个方向就越可取呢？不是。在人们已经发现的修正Powell算法的有效方法中，有一种方法是舍弃目标函数值下降最大的方向&mdash;&mdash;这看似不合理的做法恰恰蕴含了合理的结果：放弃目标函数值下降最大的方向能更好地避免各方向线性相关。关于这一点，这里就不详述了。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">一句话总结共轭方向法的过程：选定搜索方向d，使之满足<span style="color:#006400;">共轭条件</span>以及<span style="color:#006400;">下降条件</span>，在此搜索方向上通过<a href="http://www.codelast.com/?p=2348" target="_blank" rel="noopener noreferrer">精确线搜索</a>确定移动的步长，然后将当前点移动到下一点，再重新选定搜索方向，周而复始，直到满足终止条件。</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-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(128, 0, 128); ">共轭方向法的收敛性</span>：对二次函数，最多在n步（n为自变量的维数）内就可找到其极小值点。对一般的非二次函数，经适当修正后，也可以达到相同的效果。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(128, 0, 128); ">共轭方向法的收敛速度</span>：比最速下降法快，比牛顿法慢。</span></span></p>
<p>
	&nbsp;</p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color: rgb(255, 0, 0); ">【</span><font class="Apple-style-span" color="#0000FF">4</font><span style="color: rgb(255, 0, 0); ">】</span><span style="color: rgb(0, 0, 255); ">共轭梯度法</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#ff0000;">注意：下面那些长长的推导过程，其实是有部分错误的，当年我认为我弄懂了，其实到了某个推导步骤以后，我就理解错了，只不过我以为我对了，我即将在另一篇文章里写上我认为正确的推导，对不住大家了...</span><br />
	&ldquo;共轭梯度法&rdquo;是一种特殊的&ldquo;共轭方向法&rdquo;。既然叫共轭梯度法，它与梯度必然是有关系的。共轭方向法与梯度也有关系&mdash;&mdash;共轭方向法利用了目标函数的梯度信息（梯度与方向的积满足&ldquo;下降&rdquo;条件）。共轭梯度法与此关系有所区别：<span style="color:#006400;">用当前点的负梯度方向，与前面的搜索方向进行共轭化，以得到新的搜索方向</span>。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">具体来说，这个新的搜索方向是怎么计算出来的呢？推导起来比较麻烦，下面就慢慢道来。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">首先，需要说明<span style="color:#b22222;">共轭梯度法的一个理论基础（记为T1）</span>：<span style="color:#4b0082;">在迭代过程中，我们会从初始点开始，在搜索方向上通过<a href="http://www.codelast.com/?p=2348" target="_blank" rel="noopener noreferrer">精确线搜索</a>的方法，找到使目标函数值符合要求（例如，min f(X)）的步长，然后将点移动到下一点。这样不断进行下去，就会得到很多个点。在N维空间R<sup>n</sup>中，在每一个搜索方向上，都有无数个点，它们构成了一个轨迹（或者说一个集合），我们称之为<span style="color:#f00;"><a href="http://www.codelast.com/?page_id=963" target="_blank" rel="noopener noreferrer">线性流形</a></span>&mdash;&mdash;拿二维空间（二维平面）作比喻，就好像是一个点在二维平面上的移动形成的轨迹：</span></span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><span style="color:#4b0082;"><img loading="lazy" decoding="async" alt="two-dimension track" height="228" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_21.png" width="278" /></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#4b0082;">只不过在高维空间中，我们想像不出这个轨迹的样子，不过这没关系，能引申上去就好了。</span></span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;"><span style="color:#4b0082;">当目标函数是二次函数时，在这个线性流形中，每一个我们迭代到的点都是极小值点。在某些书中，你可能还会看到一种说法，称此线性流形为N维超平面，也是一个意思，不过概念太多了会让人很晕，尤其是在没有掌握足够的背景的情况下，往往不能判断一个概念与另一个概念是不是同一个意思，这样就导致理解受到影响，因此，在刚开始学习的时候，我觉得努力弄懂一个概念就好了。</span></span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">这个理论基础在推导&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="display: inline !important; ">
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">由于上面的理论基础是在目标函数为二次函数的情况下得到的，因此，在推导共轭梯度法的搜索方向的公式之前，我们先假定目标函数是二次函数：</span></span></p>
<p style="display: inline !important; ">
	&nbsp;</p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="quadratic function(x - multidimensional)" height="46" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_22.png" width="305" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">其中G为n阶对称正定矩阵。X为自变量（一个n维向量）。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">如果觉得这个X为n维向量的函数形式有点怪的话，那么还是对比一下X为1维（可以视为一个标量）的函数形式，就很清楚了：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="quadratic function(x - one dimension)" height="49" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_23.png" width="253" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在下面的推导过程中，如果你遇到看上去很&ldquo;别扭&rdquo;的式子，只要按照这样的规则来对比就行了。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">由于共轭梯度法就是与梯度相关的方法，因此我们必须要求[2]式的函数的梯度（即一阶导数）：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="gradient of dest function" height="29" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_24.png" width="210" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">现在，假设初始点为X<sub>0</sub>，我们从X<sub>0</sub>出发，先推导出前几个搜索方向的计算方法，从而总结出若干规律，进而再得到通用的公式。下面我们就开始这样做。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">在每一个迭代点处，新的搜索方向都是用前面的搜索方向与当前点的负梯度方向共轭化得到的。在初始点处，并没有&ldquo;前面的搜索方向&rdquo;，因此，初始点处的搜索方向d<sub>0</sub>简单地定为负梯度方向：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="negative gradient direction" height="31" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_25.png" width="239" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">上面的式子中，将目标函数在X<sub>0</sub>点的梯度g(X<sub>0</sub>)写为g<sub>0</sub>，是为了表达简洁。同理，</span>g(X<sub>1</sub>)也记为g<sub>1</sub>，等等。</span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">第二个迭代到的点为X<sub>1</sub>，它与X<sub>0</sub>满足关系：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="X1" height="31" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_26.png" width="206" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">这表明，点X<sub>1</sub>是在d<sub>0</sub>方向上，由X<sub>0</sub>点移动一定的距离得到的。移动的步长&alpha;<sub>0</sub>，则是通过<a href="http://www.codelast.com/?p=2348" target="_blank" rel="noopener noreferrer">精确线搜索</a>的方法计算得到的，X<sub>1</sub>是一个极小值点，在点X<sub>1</sub>处，目标函数的一阶导数为零，即：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="first derivative" height="32" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_27.png" width="456" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">所以一阶导数再乘以d<sub>0</sub>仍然为零：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="the product of g1 &amp; d0" height="31" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_28.png" width="162" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">这个式子，在紧接着的推导中马上要用到。我发现从[7]到[8]我真的太废话了，好吧，我承认我很啰嗦&hellip;</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;">既然第一个搜索方向d<sub>0</sub>毫无难度地取了负梯度方向，那么我们就来看看下一个搜索方向d<sub>1</sub>怎么获取。从共轭梯度法的定义（或者说是原则）&mdash;&mdash;新的搜索方向是用前面的搜索方向与当前点的负梯度方向共轭化得到的&mdash;&mdash;来看，d<sub>1</sub>与d<sub>0</sub>（前面的搜索方向）有关，也与-g<sub>1</sub>（当前点的负梯度方向）有关，因此，只需要假定d<sub>1</sub>是-g<sub>1</sub>与d<sub>0</sub>的线性组合即可：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="relationship of d1, -g1 &amp; d0" height="29" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_29.png" width="213" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">其中，r<sub>0</sub>是一个实数。此外，由于每一个搜索方向与前面的搜索方向都是共轭的，因此，d<sub>1</sub>与d<sub>0</sub>还要满足共轭条件：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="d1 &amp; d0 are conjugated" height="32" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_30.png" width="198" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">但是r<sub>0</sub>到底是什么值呢？只有知道了r<sub>0</sub>，我们才能算出d<sub>1</sub>，从而继续算出d<sub>2</sub>，d<sub>3</sub>，&hellip;&hellip;</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">由上面的式[8]，可以联想到，是否在式[9]的左右两边分别乘以一些矩阵或向量，从而得到一个等式，以求出r<sub>0</sub>？对，就是在式[9]的两边均左乘d<sub>0</sub><sup>T</sup>G，可推出：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="value of r0" height="161" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_31.png" width="414" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">得到了r<sub>0</sub>，我们先记下它的形式，后面再使用。紧接着，来计算其他几个式子并由它们得到一些规律。</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;">首先是在同一点处，</span>搜索方向与梯度的点积d<sub>k</sub><sup>T</sup>g<sub>k</sub>：</span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="dot product of direction vector &amp; gradient vector" height="160" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_32.png" width="320" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">看出规律来了吗？d<sub>k</sub><sup>T</sup>g<sub>k</sub>=-g<sub>k</sub><sup>T</sup>g<sub>k</sub>？像这么回事。也就是说，在同一点处，搜索方向与梯度的点积等于负梯度与梯度的点积。所以我们估计d<sub>2</sub><sup>T</sup>g<sub>2</sub>，d<sub>3</sub><sup>T</sup>g<sub>3</sub>，&hellip;&hellip;都是符合这个规律的。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">其次是在某一点处的梯度与前面所有的梯度的点积</span>g<sub>m</sub><sup>T</sup>g<sub>n</sub>(m&gt;n)：</span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="dot product of different gradient vectors" height="62" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_33.png" width="407" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">由前文所描述的共轭梯度法的理论基础T1，我们知道点X<sub>2</sub>，X<sub>3</sub>，&hellip;&hellip;均为极小值点，因此，在这些点处，目标函数的梯度为零，即g(X<sub>k</sub>)=0，所以有g<sub>2</sub><sup>T</sup>d<sub>0</sub>=0，g<sub>2</sub><sup>T</sup>d<sub>1</sub>=0，因此上面的[14]，[15]式均为零：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="dot product of different gradient vectors is zero" height="62" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_34.png" width="162" /></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">又看出一点规律没有？g<sub>m</sub><sup>T</sup>g<sub>n</sub>=0(m&gt;n)？像是这么回事。也就是说，在某一点处的梯度与前面所有梯度的点积为零。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">由上面的特例的计算，我们可以总结出一些规律并用这些规律来得到通用的结论了。假设对所有的搜索方向和梯度，有如下规律：</span></span></p>
<div style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="summarized rules" height="165" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_35.png" width="216" /></span></div>
<div>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">再重复一遍以上四个式子的含义：同一点处的搜索方向与梯度的点积等于该点处的负梯度与梯度的点积，某一点处的梯度与前面所有搜索方向的点积为0，某一点处的梯度与前面所有梯度的点积为0，某一点处的搜索方向与前面所有搜索方向共轭。</span></span></div>
<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-size:14px;"><span style="font-family:微软雅黑;">前面我们单独地求出了d<sub>0</sub>和d<sub>1</sub>，现在要来看方向d的通用的表达式怎么求了。可以设：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="general direction expression" height="57" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_36.png" style="cursor: default; " width="263" /></span></p>
<p>
	&nbsp;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">为什么可以这样表示方向d？乍一看，这个式子表示的含义是：<span style="color:#00f;">当前点的搜索方向是当前点的负梯度方向与前面所有方向的线性组合</span>&mdash;&mdash;似乎很有道理，但是有什么理论依据可以让我们这样假设呢？其实，<span style="color:#f00;">这是有线性代数理论支持的，但是这个证明涉及到更多的推导，所以这里就不扯过去了</span>。前文所述的方向d<sub>1</sub>，也是这样假设之后再求出来的。我就是这样记忆的：<span style="color:#00f;">当前点的搜索方向是当前点的负梯度方向与前面所有方向的线性组合</span>。我觉得这种感觉很直观，并且也符合我心中的设想，而且事实上它也是对的，初学者就这样记住就好了。<br />
	</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">[22]式不够直观，所以，我还是拿一个特例来演示：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="an example of the general direction expression" height="90" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_37.png" style="cursor: default; " width="438" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">这下够清晰了吧？</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">但是，如何求出[22]式中的每一个r<sub>i,m</sub>呢？我们会想到，式子的左边是一个方向向量，在共轭梯度法中，我们要保证某一点的搜索方向与前面所有搜索方向是G共轭的，因此，这提醒了我们，应该在[22]式两边均左乘一个式子，形成&ldquo;G共轭&rdquo;的表达式&mdash;&mdash;等式两边均左乘的式子就是d<sub>n</sub><sup>T</sup>G（n=0，1，&hellip;，m-1）：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="formula derivation of variable r" height="124" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_38.png" style="cursor: default; " width="336" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">我认为在共轭梯度法的推导中，最令人费解的就是这个式子。恕我愚笨，我看了4本最优化的书才搞懂，每一本书不是这里略过去了，就是那里略过去了，总有让人坐过山车的跨越感，但想明白之后的感觉终究是很舒坦的，我在这里就要把它彻底写明白了。</span></span></p>
<p>
	<span style="font-size:14px;"><span style="font-family:微软雅黑;">首先要对一个概念非常清楚：在[24]式中，我们乘的d<sub>n</sub><sup>T</sup>G，不是说我们要乘n个式子，而是说，对[22]式来说，当m选定以后，那么n就唯一选定了。例如，当m=4时，[22]式就是用来求d<sub>4</sub>的，此时，我们乘的d<sub>n</sub><sup>T</sup>G就是d<sub>3</sub><sup>T</sup>G：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="an example of calculating variable r" height="204" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_39.png" style="cursor: default; " width="517" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">写得如此详细的一个例子，看懂了吗？从这个例子中，我们知道，对n所取的任何值，在[24]式的求和式&sum;中，除最后一项外，其余所有项的值均为0&mdash;&mdash;这是因为任何一个方向与前面所有方向都是G共轭的（参看G共轭的定义）。所以现在可以写出[24]式的结果了：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="" height="34" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_40.png" style="cursor: default; " width="328" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">其中，r的写法很不直观&mdash;&mdash;其实，对每一个方向d来说，[25]式中只含有一个r，不会像[24]式那样，由于有多个r，使得必须要用复杂的下标来区分，因此此处我们完全可以用r<sub>n</sub>来代替[25]式中那个怪怪的r的表达式：</span></span></p>
<p style="text-align: center; ">
	<span style="font-family:微软雅黑;"><img loading="lazy" decoding="async" alt="expression of r" height="185" src="http://www.codelast.com/wp-content/uploads/2011/05/methods_collection_41.png" style="cursor: default; " width="371" /></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">顺便将[27]式转换了一下，得到了[29]式，即 r 的计算方法&mdash;&mdash;这就是我们日夜思念的式子啊，终于揭开面纱了！</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">（<span style="color:#f00;">待补全</span>）</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size:14px;">共轭梯度法同样会有这样的问题：经过n步迭代之后，产生的新方向不再有共轭性。所以在实际运用中，也有很多修正方向的策略。其中一种策略是：经过n步迭代之后，取负梯度方向作为新的方向。</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: rgb(128, 0, 128); ">共轭梯度法的收敛性：</span>比最速下降法的收敛性要好得多。</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%9c%80%e9%80%9f%e4%b8%8b%e9%99%8d%e6%b3%95%ef%bc%8c%e7%89%9b%e9%a1%bf%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%96%b9%e5%90%91%e6%b3%95%ef%bc%8c%e5%85%b1%e8%bd%ad%e6%a2%af%e5%ba%a6/feed/</wfw:commentRss>
			<slash:comments>18</slash:comments>
		
		
			</item>
	</channel>
</rss>
