<?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>trust region &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/trust-region/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Sun, 03 May 2020 13:28:14 +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>[原创]信赖域(Trust Region)算法是怎么一回事</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%bf%a1%e8%b5%96%e5%9f%9ftrust-region%e7%ae%97%e6%b3%95%e6%98%af%e6%80%8e%e4%b9%88%e4%b8%80%e5%9b%9e%e4%ba%8b/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%bf%a1%e8%b5%96%e5%9f%9ftrust-region%e7%ae%97%e6%b3%95%e6%98%af%e6%80%8e%e4%b9%88%e4%b8%80%e5%9b%9e%e4%ba%8b/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Mon, 28 Oct 2013 15:09:32 +0000</pubDate>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[Levenberg-Marquardt算法]]></category>
		<category><![CDATA[LM算法]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[trust region]]></category>
		<category><![CDATA[信赖域算法]]></category>
		<category><![CDATA[最优化]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=7488</guid>

					<description><![CDATA[<p>
如果你关心<a href="http://www.codelast.com/?p=7364" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">最优化</span></a>（Optimization），你一定听说过一类叫作&#8220;信赖域（Trust Region）&#8221;的算法。在本文中，我将讲述一下信赖域算法与一维搜索的区别、联系，以及信赖域算法的数学思想，实现过程。<br />
<span id="more-7488"></span><br />
<span style="background-color:#00ff00;">【1】</span>信赖域算法与一维搜索算法的区别、联系<br />
最优化的目标是找到极小值点，在这个过程中，我们需要从一个初始点开始，先确定一个搜索方向 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8277e0910d750195b448797616e091ad.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="d" /></span><script type='math/tex'>d</script> ，在这个方向上作一维搜索（line search），找到此方向上的可接受点（例如，按<a href="http://www.codelast.com/?p=7320" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">两个准则</span></a>的判定）之后，通过一定的策略调整搜索方向，然后继续在新的方向上进行一维搜索，依此类推，直到我们认为目标函数已经收敛到了极小值点。<br />
这种通过不断调整搜索方向，再在搜索方向上进行一维搜索的技术被很多很多算法采用，也取得了很实际的工程意义，但是，我们非要这样做不可吗？有没有另外一种途径，可以不通过&#8220;调整搜索方向&#8594;进行一维搜索&#8221;的步骤，也能求得极小值点？当然有，这就是信赖域算法干的好事。<br />
<span style="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><br />
为了说明这两种途径所实现的算法的区别和联系，请允许我做一个可能不太恰当，但是比较形象的比喻：</p>
<div style="text-align: center;">
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/optimization_trust_region_1.png" style="width: 433px; height: 256px;" /></div>
<p>上图表述的是：如果把求最优解的过程比喻为&#8220;造一个零件&#8221;的过程的话，那么，使用一维搜索的那些算法和信赖域算法就像是两种不同的工艺，它们分别使用不同的技术（一维搜索&#38;信赖域方法）&#8212;&#8212;即两种不同的材料作为达成最终目标的基础。<br />
作为一个了解最优化理论并不多的人，我从我看到过的书得到的感受就是：相比使用一维搜索的那一类算法，貌似信赖域算法们的应用还不够那么多。当然这仅仅是个人感觉，勿扔砖...<br />
<span style="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><br />
<span style="background-color:#00ff00;">【2】</span>信赖域算法的基本思想<br />
信赖域和line search同为最优化算法的基础算法，但是，从&#8220;Trust Region&#8221;这个名字你就可以看出，它是没有line search过程的，它是直接在一个region中&#8220;search&#8221;。<br />
在一维搜索中，从 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_550187f469eda08b9e5b55143f19c4ce.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_k}" /></span><script type='math/tex'>{x_k}</script> 点移动到下一个点的过程，可以描述为： <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dfce03f6c63c6112ec0a9e19d3390177.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_k} + {\alpha _k}{d_k}" /></span><script type='math/tex'>{x_k} + {\alpha _k}{d_k}</script> <br />
此处 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1e81ef0013ba9e0d5eedaa9c5f308662.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\alpha _k}{d_k}" /></span><script type='math/tex'>{\alpha _k}{d_k}</script> 就是在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_66eea6bfeea7fcb327d435f627a2390b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{d_k}" /></span><script type='math/tex'>{d_k}</script> 方向上的位移，可以记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> <br />
而信赖域算法是根据一定的原则，直接确定位移 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> ，同时，与一维搜索不同的是，它并没有先确定搜索方向 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_66eea6bfeea7fcb327d435f627a2390b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{d_k}" /></span><script type='math/tex'>{d_k}</script> 。如果根据&#8220;某种原则&#8221;确定的位移能使目标函数值充分下降，则扩大信赖域；若不能使目标函数值充分下降，则缩小信赖域。如此迭代下去，直到收敛。<br />
<span style="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>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%bf%a1%e8%b5%96%e5%9f%9ftrust-region%e7%ae%97%e6%b3%95%e6%98%af%e6%80%8e%e4%b9%88%e4%b8%80%e5%9b%9e%e4%ba%8b/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
如果你关心<a href="http://www.codelast.com/?p=7364" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">最优化</span></a>（Optimization），你一定听说过一类叫作&ldquo;信赖域（Trust Region）&rdquo;的算法。在本文中，我将讲述一下信赖域算法与一维搜索的区别、联系，以及信赖域算法的数学思想，实现过程。<br />
<span id="more-7488"></span><br />
<span style="background-color:#00ff00;">【1】</span>信赖域算法与一维搜索算法的区别、联系<br />
最优化的目标是找到极小值点，在这个过程中，我们需要从一个初始点开始，先确定一个搜索方向 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8277e0910d750195b448797616e091ad.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="d" /></span><script type='math/tex'>d</script> ，在这个方向上作一维搜索（line search），找到此方向上的可接受点（例如，按<a href="http://www.codelast.com/?p=7320" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">两个准则</span></a>的判定）之后，通过一定的策略调整搜索方向，然后继续在新的方向上进行一维搜索，依此类推，直到我们认为目标函数已经收敛到了极小值点。<br />
这种通过不断调整搜索方向，再在搜索方向上进行一维搜索的技术被很多很多算法采用，也取得了很实际的工程意义，但是，我们非要这样做不可吗？有没有另外一种途径，可以不通过&ldquo;调整搜索方向&rarr;进行一维搜索&rdquo;的步骤，也能求得极小值点？当然有，这就是信赖域算法干的好事。<br />
<span style="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><br />
为了说明这两种途径所实现的算法的区别和联系，请允许我做一个可能不太恰当，但是比较形象的比喻：</p>
<div style="text-align: center;">
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/optimization_trust_region_1.png" style="width: 433px; height: 256px;" /></div>
<p>上图表述的是：如果把求最优解的过程比喻为&ldquo;造一个零件&rdquo;的过程的话，那么，使用一维搜索的那些算法和信赖域算法就像是两种不同的工艺，它们分别使用不同的技术（一维搜索&amp;信赖域方法）&mdash;&mdash;即两种不同的材料作为达成最终目标的基础。<br />
作为一个了解最优化理论并不多的人，我从我看到过的书得到的感受就是：相比使用一维搜索的那一类算法，貌似信赖域算法们的应用还不够那么多。当然这仅仅是个人感觉，勿扔砖...<br />
<span style="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><br />
<span style="background-color:#00ff00;">【2】</span>信赖域算法的基本思想<br />
信赖域和line search同为最优化算法的基础算法，但是，从&ldquo;Trust Region&rdquo;这个名字你就可以看出，它是没有line search过程的，它是直接在一个region中&ldquo;search&rdquo;。<br />
在一维搜索中，从 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_550187f469eda08b9e5b55143f19c4ce.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_k}" /></span><script type='math/tex'>{x_k}</script> 点移动到下一个点的过程，可以描述为： <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dfce03f6c63c6112ec0a9e19d3390177.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_k} + {\alpha _k}{d_k}" /></span><script type='math/tex'>{x_k} + {\alpha _k}{d_k}</script> <br />
此处 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1e81ef0013ba9e0d5eedaa9c5f308662.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\alpha _k}{d_k}" /></span><script type='math/tex'>{\alpha _k}{d_k}</script> 就是在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_66eea6bfeea7fcb327d435f627a2390b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{d_k}" /></span><script type='math/tex'>{d_k}</script> 方向上的位移，可以记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> <br />
而信赖域算法是根据一定的原则，直接确定位移 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> ，同时，与一维搜索不同的是，它并没有先确定搜索方向 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_66eea6bfeea7fcb327d435f627a2390b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{d_k}" /></span><script type='math/tex'>{d_k}</script> 。如果根据&ldquo;某种原则&rdquo;确定的位移能使目标函数值充分下降，则扩大信赖域；若不能使目标函数值充分下降，则缩小信赖域。如此迭代下去，直到收敛。<br />
<span style="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><br />
关于这种寻优的方法，我这里又有一个比喻，希望能帮助你理解：</p>
<div>
	要从上海火车站去人民广场，有两种方法：<br />
	<span style="color:#b22222;">①</span>可以先定一个方向，比如先向西走，走着走着发现方向有点不对（人民广场应该是时尚地标啊，怎么越走感觉越郊区了呢），就调整一下方向，变成向东南方向走，诸如此类。</div>
<div>
	<span style="color:#b22222;">②</span>用信赖域算法，就比如，我先划一个圈，然后在这个圈里面找离人民广场可能最接近的点，如果我的圈划得太大了，一下子就划到了莘庄（不熟悉上海的同学可以查一下地图），我一步就走到了上海南站，那还得了，马上给我回来，把圈缩小到两个地铁站的距离之内，然后再在里面找离人民广场最近的点。<br />
	<span style="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><br />
	<span style="background-color:#00ff00;">【3】</span>信赖域算法的数学模型<br />
	前面说了，根据一定的原则，可以直接确定位移，那么，这个原则是什么呢？<br />
	答：利用二次模型模拟目标函数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_50bbd36e1fd2333108437a2ca378be62.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f(x)" /></span><script type='math/tex'>f(x)</script> ，再用二次模型计算出位移 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_03c7c0ace395d80182db07ae2c30f034.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s" /></span><script type='math/tex'>s</script> 。根据位移 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_03c7c0ace395d80182db07ae2c30f034.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s" /></span><script type='math/tex'>s</script> 可以确定下一点 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dc1e62cd6239629cba7578cca64d1f4f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x + s" /></span><script type='math/tex'>x + s</script> ，从而可以计算出目标函数的下降量（下降是最优化的目标），再根据下降量来决定扩大信赖域或缩小信赖域。<br />
	那么，我该如何判定要扩大还是缩小信赖域呢？为了说明这个问题，必须先描述信赖域算法的数学模型：<br />
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/optimization_trust_region_2.png" style="width: 350px; height: 111px;" /><br />
	<span style="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><br />
	第一个式子就是我们用于模拟目标函数的二次模型，其自变量为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_03c7c0ace395d80182db07ae2c30f034.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s" /></span><script type='math/tex'>s</script> ，也就是我们要求的位移。 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1cd5597a080292208723039cfd7bfd41.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{g_k}" /></span><script type='math/tex'>{g_k}</script> 为梯度， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ac8fda2ed3a75d5af87815e87a3ebc7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{G_k}" /></span><script type='math/tex'>{G_k}</script> 为Hesse矩阵，袁亚湘的书上说，如果Hesse矩阵不好计算，可以利用&ldquo;有限差分&rdquo;来近似 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ac8fda2ed3a75d5af87815e87a3ebc7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{G_k}" /></span><script type='math/tex'>{G_k}</script> （不好意思我不懂），或者用<a href="http://www.codelast.com/?p=2780" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">拟牛顿方法</span></a>来构造Hesse矩阵的近似矩阵。<br />
	第二个式子中的 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_7897c8db80031ff84df5a87ff3761308.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{h_k}" /></span><script type='math/tex'>{h_k}</script> 是第 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ce4b16b22b58894aa86c421e8759df3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="k" /></span><script type='math/tex'>k</script> 次迭代的信赖域上界（或称为信赖域半径），因此第二个式子表示的就是位移要在信赖域上界范围内。此外，第二个式子中的范数是没有指定是什么范数的，例如，是2-范数还是&infin;-范数之类的（在实际中都有算法用这些范数）。<br />
	<span style="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><br />
	现在又回到了上面的问题：我该如何判定要扩大还是缩小信赖域呢？通过衡量二次模型与目标函数的近似程度，可以作出判定：<br />
	第 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ce4b16b22b58894aa86c421e8759df3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="k" /></span><script type='math/tex'>k</script> 次迭代的实际下降量为： <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_cd697df2af53f8334f2b9ea8bb728cd3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\Delta {f_k} = {f_k} - f({x_k} + {s_k})" /></span><script type='math/tex'>\Delta {f_k} = {f_k} - f({x_k} + {s_k})</script> <br />
	第 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ce4b16b22b58894aa86c421e8759df3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="k" /></span><script type='math/tex'>k</script> 次迭代的预测下降量为： <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_b4ffbd104433208458c9e50070023c1c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\Delta {m_k} = {f_k} - m({s_k})" /></span><script type='math/tex'>\Delta {m_k} = {f_k} - m({s_k})</script> <br />
	定义比值： <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_e9259fc5cd0adbf969419b99c592ab80.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} = \frac{{\Delta {f_k}}}{{\Delta {m_k}}}" /></span><script type='math/tex'>{r_k} = \frac{{\Delta {f_k}}}{{\Delta {m_k}}}</script> <br />
	这个比值可以用于衡量二次模型与目标函数的近似程度，显然 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_4b43b0aee35624cd95b910189b3dc231.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="r" /></span><script type='math/tex'>r</script> 值越接近1越好。</p>
<p>	由此，我们就可以给出一个简单的信赖域算法了。<br />
	<span style="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><br />
	<span style="background-color:#00ff00;">【4】</span>信赖域算法的步骤<br />
	一个考虑周全的信赖域算法可能非常麻烦，为了说明其步骤，这里只说明基本的迭代步骤：</div>
<ul>
<li>
		从初始点 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_892581f6aefecae90be73076e1aeee5c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_0}" /></span><script type='math/tex'>{x_0}</script> ，初始信赖域半径 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dd8c818172ac708f9bb6dca661127a81.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{h_0} = \left\| {{g_0}} \right\|" /></span><script type='math/tex'>{h_0} = \left\| {{g_0}} \right\|</script> 开始迭代</li>
<li>
		到第 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ce4b16b22b58894aa86c421e8759df3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="k" /></span><script type='math/tex'>k</script> 步时，计算 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1cd5597a080292208723039cfd7bfd41.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{g_k}" /></span><script type='math/tex'>{g_k}</script> 和 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ac8fda2ed3a75d5af87815e87a3ebc7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{G_k}" /></span><script type='math/tex'>{G_k}</script> </li>
<li>
		解信赖域模型，求出位移 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> ，计算 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_3b0e65747eafbb19ab7bc40d35bce04c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k}" /></span><script type='math/tex'>{r_k}</script> </li>
<li>
		若 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c4545c6fd3f587a190de62f5726c19e7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} \le 0.25" /></span><script type='math/tex'>{r_k} \le 0.25</script> ，说明步子迈得太大了，应缩小信赖域半径，令 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_3122146e97379c67d68fbc1fd4767fac.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{h_{k + 1}} = \frac{{\left\| {{s_k}} \right\|}}{4}" /></span><script type='math/tex'>{h_{k + 1}} = \frac{{\left\| {{s_k}} \right\|}}{4}</script> </li>
<li>
		若 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_e60e3f12948c020dd8caa32bb9465855.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} \ge 0.75" /></span><script type='math/tex'>{r_k} \ge 0.75</script> 且 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_6a119a8b314804d0f5525b0565bb5905.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\left\| {{s_k}} \right\| = {h_k}" /></span><script type='math/tex'>\left\| {{s_k}} \right\| = {h_k}</script> ，说明这一步已经迈到了信赖域半径的边缘，并且步子有点小，可以尝试扩大信赖域半径，令 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_98a4587baebd5120b017bdeae7f692d1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{h_{k + 1}} = 2{h_k}" /></span><script type='math/tex'>{h_{k + 1}} = 2{h_k}</script> </li>
<li>
		若 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_63c50442db03e5c67898fd58fbf482b0.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="0.25 < {r_k} < 0.75" /></span><script type='math/tex'>0.25 < {r_k} < 0.75</script> ，说明这一步迈出去之后，处于&ldquo;可信赖&rdquo;和&ldquo;不可信赖&rdquo;之间，可以维持当前的信赖域半径，令 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_cb2e219c1b08ff28ea07e76ba0fb2dbc.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{h_{k + 1}} = {h_k}" /></span><script type='math/tex'>{h_{k + 1}} = {h_k}</script> </li>
<li>
		若 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_34051880f1cad914a6448bce6089ff97.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} \le 0" /></span><script type='math/tex'>{r_k} \le 0</script> ，说明函数值是向着上升而非下降的趋势变化了（与最优化的目标相反），这说明这一步迈得错得&ldquo;离谱&rdquo;了，这时不应该走到下一点，而应&ldquo;原地踏步&rdquo;，即 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_f27914c23c0fac18442dc37b7fc9f184.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_{k + 1}} = {x_k}" /></span><script type='math/tex'>{x_{k + 1}} = {x_k}</script> ，并且和上面 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c4545c6fd3f587a190de62f5726c19e7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} \le 0.25" /></span><script type='math/tex'>{r_k} \le 0.25</script> 的情况一样缩小信赖域。反之，在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_51294d6fb4a7529442d015152a384fd4.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} > 0" /></span><script type='math/tex'>{r_k} > 0</script> 的情况下，都可以走到下一点，即 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1cabf6797197dc77c50fe830118a329b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_{k + 1}} = {x_k} + {s_k}" /></span><script type='math/tex'>{x_{k + 1}} = {x_k} + {s_k}</script> </li>
</ul>
<div>
	<span style="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><br />
	<span style="background-color:#00ff00;">【5】</span>最重要的一种信赖域算法：<span style="color:#0000ff;">Levenberg-Marquardt算法</span><br />
	当信赖域模型中的范数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_aedba953352e84a8a4e7db5979dac82b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\left\| s \right\| \le {h_k}" /></span><script type='math/tex'>\left\| s \right\| \le {h_k}</script> 取2-范数时（即 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_d1fe74ea11c0c4dbdf236f16ad7e4f2d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\left\| s \right\|_2} \le {h_k}" /></span><script type='math/tex'>{\left\| s \right\|_2} \le {h_k}</script> ），就得到了Levenberg-Marquardt算法（简称<span style="color:#0000ff;">LM算法</span>）的数学模型：<br />
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/optimization_trust_region_3.png" style="width: 350px; height: 111px;" /><br />
	具体请看<a href="http://www.codelast.com/?p=29" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">这里</span></a>。<br />
	<span style="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><br />
	<span style="background-color:#00ff00;">【6】</span>信赖域算法的收敛性<br />
	信赖域算法具有整体收敛性。这个证明我没看（太长了），此处略。<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>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%bf%a1%e8%b5%96%e5%9f%9ftrust-region%e7%ae%97%e6%b3%95%e6%98%af%e6%80%8e%e4%b9%88%e4%b8%80%e5%9b%9e%e4%ba%8b/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] LM(Levenberg-Marquard)算法的实现</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9blm%e7%ae%97%e6%b3%95%e7%9a%84%e5%ae%9e%e7%8e%b0/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9blm%e7%ae%97%e6%b3%95%e7%9a%84%e5%ae%9e%e7%8e%b0/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Mon, 13 Sep 2010 18:09:35 +0000</pubDate>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[Levenberg-Marquardt]]></category>
		<category><![CDATA[LM算法]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[trust region]]></category>
		<category><![CDATA[信赖域]]></category>
		<category><![CDATA[最优化]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=29</guid>

					<description><![CDATA[<p>
	&#160;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px;">LM算法，全称为Levenberg-Marquard算法，它可用于解决非线性最小二乘问题，多用于曲线拟合等场合。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px;">LM算法的实现并不算难，它的关键是用模型函数  <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script>  对待估参数向量 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_83878c91171338902e0fe0fb97a8c47a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="p" /></span><script type='math/tex'>p</script> 在其邻域内做线性近似，忽略掉二阶以上的导数项，从而转化为线性最小二乘问题，它具有收敛速度快等优点。LM算法属于一种&#8220;<a href="http://www.codelast.com/?p=7488" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 0, 0);">信赖域法</span></a>&#8221;&#8212;&#8212;所谓的信赖域法，此处稍微解释一下：在最优化算法中，都是要求一个函数的极小值，每一步迭代中，都要求目标函数值是下降的，而信赖域法，顾名思义，就是从初始点开始，先假设一个可以信赖的最大位移 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_03c7c0ace395d80182db07ae2c30f034.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s" /></span><script type='math/tex'>s</script> ，然后在以当前点为中心，以 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_03c7c0ace395d80182db07ae2c30f034.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s" /></span><script type='math/tex'>s</script> 为半径的区域内，通过寻找目标函数的一个近似函数（二次的）的最优点，来求解得到真正的位移。在得到了位移之后，再计算目标函数值，如果其使目标函数值的下降满足了一定条件，那么就说明这个位移是可靠的，则继续按此规则迭代计算下去；如果其不能使目标函数值的下降满足一定的条件，则应减小信赖域的范围，再重新求解。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px;">事实上，你从所有可以找到的资料里看到的LM算法的说明，都可以找到类似于&#8220;如果目标函数值增大，则调整某系数再继续求解；如果目标函数值减小，则调整某系数再继续求解&#8221;的迭代过程，这种过程与上面所说的信赖域法是非常相似的，所以说LM算法是一种信赖域法。</span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&#160;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span id="more-29"></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span style="color: rgb(0, 0, 0);"><span style="font-size: 14px;">LM算法需要对每一个待估参数求偏导，所以，如果你的目标函数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 非常复杂，或者待估参数相当地多，那么可能不适合使用LM算法，而可以选择Powell算法&#8212;&#8212;Powell算法不需要求导。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&#160;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span style="color: rgb(0, 0, 0);"><span style="font-size: 14px;">至于这个求导过程是如何实现的，我还不能给出建议，我使用过的方法是拿到函数的方程，然后手工计算出其偏导数方程，进而在函数中直接使用，这样做是最直接，求导误差也最小的方式。不过，在你不知道函数的形式之前，你当然就不能这样做了&#8212;&#8212;例如，你提供给了用户在界面上输入数学函数式的机会，然后在程序中解析其输入的函数，再做后面的处理。在这种情况下，我猜是需要使用数值求导算法的，但我没有亲自试验过这样做的效率，因为一些优秀的求导算法&#8212;&#8212;例如<a href="http://www.codelast.com/?p=1419" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Ridders算法</span></a>&#8212;&#8212;在一次求导数值过程中，需要计算的函数值次数也会达到5次以上。这样的话，它当然要比手工求出导函数（只需计算一次，就可以得到导数值）效率要差得多了。不过，我个人估计（没有任何依据的，只是猜的）：依赖于LM算法的高效，就算添加了一个数值求导的&#8220;拖油瓶&#8221;，整个最优化过程下来，它仍然会优于Powell等方法。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
	<span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; 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></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);">在<a href="http://www.codelast.com/?p=7488" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这篇</span></a>解释信赖域算法的文章中，我们已经知道了LM算法的数学模型：<br />
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/optimization_trust_region_3.png" style="width: 350px; height: 111px;" /><br />
	可以证明，此模型可以通过解方程组</span></span></span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8838fa9623a6308c220121c6059c0890.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="({G_k} + \mu I)s = - {g_k}" /></span><script type='math/tex'>({G_k} + \mu I)s = - {g_k}</script> <span style="color:#000000;"><span style="font-size: 14px;">确定</span></span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> <span style="color:#000000;">来<span style="font-size: 14px;">表征。<br />
	即：LM算法要确定一个</span></span></span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_5e9a87eedf6e15dc5bcd9c7b59006bee.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\mu \ge 0" /></span><script type='math/tex'>\mu \ge 0</script> <span style="font-size: 14px; color: rgb(0, 0, 0); font-family: 微软雅黑;">，使得</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_773d2559f0d1eed1850c883a6358cdc6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{G_k} + \mu I" /></span><script type='math/tex'>{G_k} + \mu I</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">正定，并解线性方程组</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_7e3ce21124c14a52c24137db707afa2e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="({G_k} + \mu I){s_k} = - {g_k}" /></span><script type='math/tex'>({G_k} + \mu I){s_k} = - {g_k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">求出</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">。</span><br />
	<span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; font-size: 14px; line-height: 20px; 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>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9blm%e7%ae%97%e6%b3%95%e7%9a%84%e5%ae%9e%e7%8e%b0/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	&nbsp;</p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px;">LM算法，全称为Levenberg-Marquard算法，它可用于解决非线性最小二乘问题，多用于曲线拟合等场合。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px;">LM算法的实现并不算难，它的关键是用模型函数  <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script>  对待估参数向量 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_83878c91171338902e0fe0fb97a8c47a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="p" /></span><script type='math/tex'>p</script> 在其邻域内做线性近似，忽略掉二阶以上的导数项，从而转化为线性最小二乘问题，它具有收敛速度快等优点。LM算法属于一种&ldquo;<a href="http://www.codelast.com/?p=7488" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 0, 0);">信赖域法</span></a>&rdquo;&mdash;&mdash;所谓的信赖域法，此处稍微解释一下：在最优化算法中，都是要求一个函数的极小值，每一步迭代中，都要求目标函数值是下降的，而信赖域法，顾名思义，就是从初始点开始，先假设一个可以信赖的最大位移 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_03c7c0ace395d80182db07ae2c30f034.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s" /></span><script type='math/tex'>s</script> ，然后在以当前点为中心，以 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_03c7c0ace395d80182db07ae2c30f034.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s" /></span><script type='math/tex'>s</script> 为半径的区域内，通过寻找目标函数的一个近似函数（二次的）的最优点，来求解得到真正的位移。在得到了位移之后，再计算目标函数值，如果其使目标函数值的下降满足了一定条件，那么就说明这个位移是可靠的，则继续按此规则迭代计算下去；如果其不能使目标函数值的下降满足一定的条件，则应减小信赖域的范围，再重新求解。</span></span></p>
<p>
	<span style="font-family:微软雅黑;"><span style="font-size: 14px;">事实上，你从所有可以找到的资料里看到的LM算法的说明，都可以找到类似于&ldquo;如果目标函数值增大，则调整某系数再继续求解；如果目标函数值减小，则调整某系数再继续求解&rdquo;的迭代过程，这种过程与上面所说的信赖域法是非常相似的，所以说LM算法是一种信赖域法。</span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&nbsp;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span id="more-29"></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span style="color: rgb(0, 0, 0);"><span style="font-size: 14px;">LM算法需要对每一个待估参数求偏导，所以，如果你的目标函数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 非常复杂，或者待估参数相当地多，那么可能不适合使用LM算法，而可以选择Powell算法&mdash;&mdash;Powell算法不需要求导。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&nbsp;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span style="color: rgb(0, 0, 0);"><span style="font-size: 14px;">至于这个求导过程是如何实现的，我还不能给出建议，我使用过的方法是拿到函数的方程，然后手工计算出其偏导数方程，进而在函数中直接使用，这样做是最直接，求导误差也最小的方式。不过，在你不知道函数的形式之前，你当然就不能这样做了&mdash;&mdash;例如，你提供给了用户在界面上输入数学函数式的机会，然后在程序中解析其输入的函数，再做后面的处理。在这种情况下，我猜是需要使用数值求导算法的，但我没有亲自试验过这样做的效率，因为一些优秀的求导算法&mdash;&mdash;例如<a href="http://www.codelast.com/?p=1419" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Ridders算法</span></a>&mdash;&mdash;在一次求导数值过程中，需要计算的函数值次数也会达到5次以上。这样的话，它当然要比手工求出导函数（只需计算一次，就可以得到导数值）效率要差得多了。不过，我个人估计（没有任何依据的，只是猜的）：依赖于LM算法的高效，就算添加了一个数值求导的&ldquo;拖油瓶&rdquo;，整个最优化过程下来，它仍然会优于Powell等方法。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
	<span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; 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></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);">在<a href="http://www.codelast.com/?p=7488" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这篇</span></a>解释信赖域算法的文章中，我们已经知道了LM算法的数学模型：<br />
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/optimization_trust_region_3.png" style="width: 350px; height: 111px;" /><br />
	可以证明，此模型可以通过解方程组</span></span></span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8838fa9623a6308c220121c6059c0890.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="({G_k} + \mu I)s = - {g_k}" /></span><script type='math/tex'>({G_k} + \mu I)s = - {g_k}</script> <span style="color:#000000;"><span style="font-size: 14px;">确定</span></span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> <span style="color:#000000;">来<span style="font-size: 14px;">表征。<br />
	即：LM算法要确定一个</span></span></span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_5e9a87eedf6e15dc5bcd9c7b59006bee.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\mu \ge 0" /></span><script type='math/tex'>\mu \ge 0</script> <span style="font-size: 14px; color: rgb(0, 0, 0); font-family: 微软雅黑;">，使得</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_773d2559f0d1eed1850c883a6358cdc6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{G_k} + \mu I" /></span><script type='math/tex'>{G_k} + \mu I</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">正定，并解线性方程组</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_7e3ce21124c14a52c24137db707afa2e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="({G_k} + \mu I){s_k} = - {g_k}" /></span><script type='math/tex'>({G_k} + \mu I){s_k} = - {g_k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">求出</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">。</span><br />
	<span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; font-size: 14px; line-height: 20px; 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><br />
	<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;"> 下面来看看LM算法的基本步骤：<br />
	</span></p>
<ul>
<li style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">从初始点</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_892581f6aefecae90be73076e1aeee5c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_0}" /></span><script type='math/tex'>{x_0}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_d63edeaa2da65b5eb9315cb67f2aef33.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\mu _0} > 0" /></span><script type='math/tex'>{\mu _0} > 0</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">开始迭代</span></li>
<li style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">到第 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ce4b16b22b58894aa86c421e8759df3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="k" /></span><script type='math/tex'>k</script> 步时，计算</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_550187f469eda08b9e5b55143f19c4ce.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_k}" /></span><script type='math/tex'>{x_k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">和</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fd211701b4a46ba1dc0a286b482358aa.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\mu _k}" /></span><script type='math/tex'>{\mu _k}</script> </li>
<li style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">分解矩阵</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8ac50fc83ecb275c766e83ae5ad0e587.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{G_k} + {\mu _k}I" /></span><script type='math/tex'>{G_k} + {\mu _k}I</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，若不正定，令</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_945ae9d814c12aa3d30295bfc0f46906.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\mu _k} = 4{\mu _k}" /></span><script type='math/tex'>{\mu _k} = 4{\mu _k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">并重复到正定为止</span></li>
<li style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">解线性方程组</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_39bb97dce4480ed372e0cf0c8b4d7813.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="({G_k} + {\mu _k}I){s_k} = - {g_k}" /></span><script type='math/tex'>({G_k} + {\mu _k}I){s_k} = - {g_k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">求出 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_73194efc87788b133d9278ade98decd5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{s_k}" /></span><script type='math/tex'>{s_k}</script> 并计算</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_3b0e65747eafbb19ab7bc40d35bce04c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k}" /></span><script type='math/tex'>{r_k}</script> </li>
<li style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">若</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_890c822af8cb2c55c7738f71331569b9.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} < 0.25" /></span><script type='math/tex'>{r_k} < 0.25</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，令</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dedbf28098ef6d24e2b3828ea11e303b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\mu _{k + 1}} = 4{\mu _k}" /></span><script type='math/tex'>{\mu _{k + 1}} = 4{\mu _k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">；若</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c498579afb29a1cc30954e8b834dfb97.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} > 0.75" /></span><script type='math/tex'>{r_k} > 0.75</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，令</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_bec7e26d65c86ecf3e0a820cb9f09695.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\mu _{k + 1}} = \frac{{{\mu _k}}}{2}" /></span><script type='math/tex'>{\mu _{k + 1}} = \frac{{{\mu _k}}}{2}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">；若</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_19d7e5da4d211b89524a3da89333dc53.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="0.25 \le {r_k} \le 0.75" /></span><script type='math/tex'>0.25 \le {r_k} \le 0.75</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，令</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_946e5235b551f6d30398f23d112c9954.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\mu _{k + 1}} = {\mu _k}" /></span><script type='math/tex'>{\mu _{k + 1}} = {\mu _k}</script> </li>
<li style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">若</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_34051880f1cad914a6448bce6089ff97.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} \le 0" /></span><script type='math/tex'>{r_k} \le 0</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，说明函数值是向着上升而非下降的趋势变化了（与最优化的目标相反），这说明这一步走错了，而且错得&ldquo;离谱&rdquo;，此时，不应该走到下一点，而应&ldquo;原地踏步&rdquo;，即</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_f27914c23c0fac18442dc37b7fc9f184.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_{k + 1}} = {x_k}" /></span><script type='math/tex'>{x_{k + 1}} = {x_k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，并且和上面</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_890c822af8cb2c55c7738f71331569b9.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} < 0.25" /></span><script type='math/tex'>{r_k} < 0.25</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">的情况一样对</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fd211701b4a46ba1dc0a286b482358aa.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{\mu _k}" /></span><script type='math/tex'>{\mu _k}</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">进行处理。反之，在</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_51294d6fb4a7529442d015152a384fd4.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{r_k} > 0" /></span><script type='math/tex'>{r_k} > 0</script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">的情况下，都可以走到下一点，即</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1cabf6797197dc77c50fe830118a329b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_{k + 1}} = {x_k} + {s_k}" /></span><script type='math/tex'>{x_{k + 1}} = {x_k} + {s_k}</script> </li>
<li style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">迭代的终止条件：</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_16fbb5f34444df12659bd64cb64d5c7c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\left\| {{g_k}} \right\| < \varepsilon " /></span><script type='math/tex'>\left\| {{g_k}} \right\| < \varepsilon </script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">，其中</span> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c691dc52cc1ad756972d4629934d37fd.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\varepsilon " /></span><script type='math/tex'>\varepsilon </script> <span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px;">是一个指定的小正数（大家可以想像一下二维平面上的寻优过程（函数图像类似于抛物线），当接近极小值点时，迭代点的梯度趋于0）</span></li>
</ul>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; font-size: 14px; line-height: 20px; 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><br />
	<span style="font-family:微软雅黑;"><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);">从上面的步骤可见，LM求解过程中需要用到求解线性方程组的算法，一般我们使用</span></span></span><span style=""><span style="font-size: 14px;"><a href="http://www.codelast.com/?p=1288" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">高斯约当消元法</span></a></span></span><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);">，因为它非常稳定&mdash;&mdash;虽然它不是最快最好的算法。<br />
	同时，上面的算法步骤也包含对矩阵进行分解的子步骤。为什么要先分解矩阵，再解线性方程组？貌似是这样的（数学不好的人再次泪奔）：不分解矩阵使之正定，就无法确定那个线性方程组是有解的。</span></span></span><span style=""><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);"><a href="http://zh.wikipedia.org/wiki/%E7%9F%A9%E9%98%B5%E5%88%86%E8%A7%A3" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">矩阵分解</span></a></span></span></span><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);">有很多算法，例如</span></span></span><span style=""><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);"><a href="http://zh.wikipedia.org/wiki/LU%E5%88%86%E8%A7%A3" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">LU分解</span></a></span></span></span><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);">等，这方面我没有看。</span></span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);"><a href="http://www.ics.forth.gr/~lourakis/levmar/levmar.pdf" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这里</span></a>有一篇很不错的文章，解释了如何实现LM算法，大家可以参考一下。</span></span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="font-family:微软雅黑;"><span><span style="font-size: 14px;"><span style="color: rgb(0, 0, 0);">需要说明的是，这是非线性无约束的问题，如果待估参数是有约束的（例如参数在某一范围内变动），要想用在LM算法中，那就是约束最优化问题了，这是一个big topic，以我目前的知识储备，尚不能解释好，请大家另寻资料吧。</span></span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
	<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%9blm%e7%ae%97%e6%b3%95%e7%9a%84%e5%ae%9e%e7%8e%b0/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
