# Levenberg–Marquardt算法

**Levenberg–Marquardt算法**（LM）是一种迭代数值方法，用于求解非线性最小二乘问题，即寻找使一组非线性函数的平方和最小化的参数。它通过在每一步中加入可调阻尼项，在Gauss–Newton法与梯度下降之间进行插值。Ceres Solver文档将其描述为求解非线性最小二乘问题最流行的算法，也是最早被提出的信赖域算法。<sup>[1](https://ceres-solver.readthedocs.io/latest/nnls_solving.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 求解的问题 | 最小化\( n \)个变量中\( m \)个非线性函数的平方和<sup>[2](https://www.math.utah.edu/software/minpack/minpack/lmdif.html)</sup> |
| 原始文献 | 肯尼斯·莱文贝格，*Quarterly of Applied Mathematics* 2(2)，164–168，1944年7月；唐纳德·W·马夸特，*SIAM J. Appl. Math.* 11(2)，431–441，1963年6月<sup>[3](https://cir.nii.ac.jp/crid/1360011142941168640?lang=en)</sup><sup> • </sup><sup>[4](https://epubs.siam.org/doi/10.1137/0111030)</sup> |
| 核心步骤 | 求解阻尼正规方程\( (J^{\top}J + \lambda D^{\top}D)\,\Delta x = -J^{\top}F \)<sup>[1](https://ceres-solver.readthedocs.io/latest/nnls_solving.html)</sup> |
| 参考实现 | MINPACK子程序LMDIF（加博、希尔斯特伦和莫雷，阿贡国家实验室，1980年3月）<sup>[2](https://www.math.utah.edu/software/minpack/minpack/lmdif.html)</sup> |
| 收敛性 | 在标准假设下局部二次收敛；作为信赖域方法看待时全局收敛<sup>[5](https://users.cecs.anu.edu.au/~robert/publications/YO07.pdf)</sup><sup> • </sup><sup>[6](https://repository.rice.edu/bitstreams/2d2b6c5d-27b0-40b1-b304-d390faed352d/download)</sup> |
| 已知弱点 | 在狭窄弯曲的谷地中进展缓慢；在代价函数非常平坦的区域可能迷失<sup>[7](https://arxiv.org/abs/1201.5885)</sup> |
| 典型用途 | 曲线拟合、光束法平差、相机标定，以及训练小型到中型神经网络<sup>[8](https://ceres-solver.readthedocs.io/latest/users.html)</sup><sup> • </sup><sup>[9](https://www.sciencedirect.com/science/article/pii/S1474667017308492)</sup> |

## 所求解的问题

给定残差向量\( F(x) \)，非线性最小二乘问题是最小化代价

\[ C(x) = \tfrac{1}{2}\,\|F(x)\|^{2}. \]

在每次迭代中，残差函数由其雅可比矩阵\( J(x) \)线性近似，由此得到的线性最小二乘子问题为

\[ \min_{\Delta x} \; \tfrac{1}{2}\,\|J(x)\,\Delta x + F(x)\|^{2}. \]

不加进一步限制地求解此问题即得到Gauss–Newton步，它在解附近收敛很快，但当线性化质量较差时可能产生剧烈而无用的步长。莱文贝格的贡献在于证明：通过添加一个控制步长的阻尼项，可以用标准方法的扩展来求解该问题，从而确保初始解得到改进。<sup>[10](https://cs.uwaterloo.ca/~y328yu/classics/levenberg.pdf)</sup>

## 阻尼步

该方法在每次迭代中求解如下形式的无约束问题<sup>[1](https://ceres-solver.readthedocs.io/latest/nnls_solving.html)</sup>

\[ \arg\min_{\Delta x} \; \tfrac{1}{2}\,\|J\,\Delta x + F\|^{2} + \lambda\,\|D\,\Delta x\|^{2}, \]

由此得到阻尼正规方程

\[ \left(J^{\top}J + \lambda\,D^{\top}D\right)\Delta x = -J^{\top}F. \]

其中\( \lambda \)是阻尼（或Levenberg–Marquardt）参数，\( D \)是非负对角缩放矩阵；在Ceres中，\( D(x) \)通常取\( J(x)^{\top}J(x) \)对角线的平方根。<sup>[1](https://ceres-solver.readthedocs.io/latest/nnls_solving.html)</sup> \( \lambda \)的作用可由一个单调性观察得出：步长平方\( \Delta^{2} = \delta\theta^{\top}D^{\top}D\,\delta\theta \)是\( \lambda \)的单调递减函数，因此当\( \lambda \)足够大时，算法沿下降方向取任意小的步长。<sup>[7](https://arxiv.org/abs/1201.5885)</sup> 当\( \lambda \)非常大时，步长趋近于缩放梯度步，

\[ \delta\theta \approx -\frac{1}{\lambda}\,(D^{\top}D)^{-1}\,\nabla C, \]

因此大阻尼恢复梯度下降，小阻尼恢复Gauss–Newton。<sup>[7](https://arxiv.org/abs/1201.5885)</sup>

**自适应阻尼。** 各实现根据线性模型对代价实际下降的预测好坏来调整\( \lambda \)（或等价地调整信赖域半径\( \mu \)，\( \lambda \)与\( \mu \)成反比）。Ceres计算增益比

\[ \rho = \frac{\|F(x + \Delta x)\|^{2} - \|F(x)\|^{2}}{\|J\,\Delta x + F\|^{2} - \|F(x)\|^{2}}, \]

当\( \rho \)超过阈值时接受该步，预测良好时增大半径，预测不佳时减小半径。<sup>[1](https://ceres-solver.readthedocs.io/latest/nnls_solving.html)</sup> 缩放矩阵对不变性很重要：对于适当选择的\( D^{\top}D \)，算法产生的迭代点对参数的尺度变换不变。<sup>[7](https://arxiv.org/abs/1201.5885)</sup>

## 历史

肯尼斯·莱文贝格当时在法兰克福兵工厂工作，于1944年在*Quarterly of Applied Mathematics*上发表了该方法，题为《某些非线性最小二乘问题的求解方法》。<sup>[3](https://cir.nii.ac.jp/crid/1360011142941168640?lang=en)</sup><sup> • </sup><sup>[10](https://cs.uwaterloo.ca/~y328yu/classics/levenberg.pdf)</sup> 唐纳德·W·马夸特的论文《非线性参数最小二乘估计的一种算法》于1962年6月13日投稿，1963年6月发表在*SIAM Journal on Applied Mathematics*（第11卷第2期，第431–441页），将该方法重塑为此后广泛使用的形式。<sup>[4](https://epubs.siam.org/doi/10.1137/0111030)</sup> 据GraphPad曲线拟合指南记载，该算法还被吉拉尔、温和莫里森独立重新发现。<sup>[11](https://www.graphpad.com/guides/prism/latest/curve-fitting/reg_who_developed_nonlinear_regres.htm)</sup>

该算法的现代形式在很大程度上归功于豪尔赫·J·莫雷，他于1978年提出了该方法某一版本的稳健高效实现，并证明其具有强收敛性质；该实现包含在MINPACK中，在实践中已被证明非常成功。<sup>[12](https://arphymat.univ-rennes1.fr/publis/2015%20S.%20Mansour%20thesis.pdf)</sup>

## 实现

**MINPACK。** LMDIF是阿贡国家实验室MINPACK库的一部分（加博、希尔斯特伦和莫雷，1980年3月），它应用改进的Levenberg–Marquardt方法最小化\( n \)个变量的\( m \)个非线性函数的平方和；当用户未提供雅可比矩阵时，用前向差分近似。<sup>[2](https://www.math.utah.edu/software/minpack/minpack/lmdif.html)</sup> LMDIF在每次内迭代中确定Levenberg–Marquardt参数，并对函数、参数和梯度范数进行收敛检验。<sup>[13](https://fortran-lang.github.io/minpack/proc/lmdif.html)</sup>

**SciPy。** `least_squares`例程提供`method='lm'`，即MINPACK中实现的Levenberg–Marquardt算法；它不处理边界约束或稀疏雅可比矩阵，通常是小型无约束问题最有效的方法。`curve_fit`对无约束问题默认使用`lm`，提供边界时则使用信赖域反射方法。<sup>[14](https://scipy.github.io/devdocs/reference/generated/scipy.optimize.least_squares.html)</sup><sup> • </sup><sup>[15](https://cache-docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html)</sup>

**MATLAB。** `lsqcurvefit`和`lsqnonlin`提供`"levenberg-marquardt"`作为算法选项；信赖域反射算法不求解欠定系统，因此在这种情况下MATLAB使用Levenberg–Marquardt，而当问题包含边界约束时，LM迭代将落在边界外的提议点投影到最近的可行点。<sup>[16](https://www.mathworks.com/help/optim/ug/lsqcurvefit.html)</sup><sup> • </sup><sup>[17](https://www.mathworks.com/help/optim/ug/least-squares-model-fitting-algorithms.html)</sup>

**Ceres Solver。** Google的Ceres使用Levenberg–Marquardt作为默认信赖域策略，并实现了精确步变体和近似步变体两种形式；该策略使用对角矩阵正则化信赖域步，该对角线的默认下界和上界分别为\( 10^{-6} \)和\( 10^{32} \)，初始信赖域半径为\( 10^{4} \)，当半径低于\( 10^{-32} \)时终止。<sup>[1](https://ceres-solver.readthedocs.io/latest/nnls_solving.html)</sup><sup> • </sup><sup>[18](https://ceres-solver.readthedocs.io/latest/solving_faqs.html)</sup> Ceres及其LM步计算被用于Google产品（如街景和ARCore）中的光束法平差和SLAM，也被Blender、COLMAP和OpenMVG等项目使用。<sup>[8](https://ceres-solver.readthedocs.io/latest/users.html)</sup>

## 收敛性与局限性

在标准假设下，该方法局部二次收敛；当作为信赖域方法看待时，所得算法全局收敛，即从任意起点收敛到驻点。<sup>[5](https://users.cecs.anu.edu.au/~robert/publications/YO07.pdf)</sup><sup> • </sup><sup>[6](https://repository.rice.edu/bitstreams/2d2b6c5d-27b0-40b1-b304-d390faed352d/download)</sup>

特兰斯特鲁姆、马赫塔和塞斯纳这几位研究该算法在非线性最小二乘拟合中行为的物理学家记录了两种实际失败模式：当算法必须在通往最佳拟合的途中穿越狭窄峡谷时，可能收敛缓慢；当代价函数非常平坦时，它可能采取大而无控制的步长，在参数空间中迷失，这一现象与参数蒸发有关。<sup>[7](https://arxiv.org/abs/1201.5885)</sup> 他们提出的补救方法是测地加速度，对提议步长添加二阶修正；在一些测试问题上，它收敛所需的雅可比矩阵计算次数平均降至原来的七十分之一，并同时提高了成功率和拟合质量。<sup>[7](https://arxiv.org/abs/1201.5885)</sup>

## 扩展与应用

基本方法已沿若干方向得到扩展。随机Levenberg–Marquardt方法处理带噪声的目标函数值和随机模型，前提是以概率达到足够精度。<sup>[19](https://arxiv.org/abs/1807.02176)</sup> Riemannian版本将方法推广到流形上的优化。<sup>[20](https://arxiv.org/abs/2210.00253)</sup> 针对非光滑正则化最小二乘的变体最小化光滑最小二乘项与非光滑项\( h \)之和，在Lipschitz连续性假设下全局收敛到一阶驻点。<sup>[21](https://arxiv.org/abs/2301.02347)</sup>

在机器学习中，LM通过将训练损失视为最小二乘问题来训练神经网络；它被认为是为此目的最有效的算法之一，但其计算复杂度和内存开销——源于由两个大型雅可比乘积构造Gauss–Newton矩阵——使其对大型网络不实用，因此人们提出了Krylov子空间LM和混合子空间LM等子空间变体以降低这些开销。<sup>[9](https://www.sciencedirect.com/science/article/pii/S1474667017308492)</sup><sup> • </sup><sup>[22](https://arxiv.org/abs/2609.00789)</sup> 一种基于反向传播的Gauss–Newton近似计算方法使渐近运行时间缩短，缩短的倍数与输出节点数量同阶。<sup>[23](https://openaccess.city.ac.uk/id/eprint/4369/)</sup>

## References

1. [Levenberg–Marquardt, Ceres Solver documentation: Solving Non-linear Least Squares](https://ceres-solver.readthedocs.io/latest/nnls_solving.html)
2. [Documentation for MINPACK subroutine LMDIF, Argonne National Laboratory, March 1980](https://www.math.utah.edu/software/minpack/minpack/lmdif.html)
3. [Kenneth Levenberg (1944). A method for the solution of certain non-linear problems in least squares. Quarterly of Applied Mathematics 2(2), 164–168](https://cir.nii.ac.jp/crid/1360011142941168640?lang=en)
4. [Donald W. Marquardt (1963). An Algorithm for Least-Squares Estimation of Nonlinear Parameters. SIAM J. Appl. Math. 11(2), 431–441](https://epubs.siam.org/doi/10.1137/0111030)
5. [Robert Moylan? — Trust region methods lecture notes, ANU: local quadratic convergence of the Levenberg–Marquardt method](https://users.cecs.anu.edu.au/~robert/publications/YO07.pdf)
6. [Stability and Regularity, Rice University repository: global convergence of the Levenberg–Marquardt method as a trust region method](https://repository.rice.edu/bitstreams/2d2b6c5d-27b0-40b1-b304-d390faed352d/download)
7. [Transtrum, Machta, Sethna (2012). Improvements to the Levenberg–Marquardt algorithm for nonlinear least-squares minimization. arXiv:1201.5885](https://arxiv.org/abs/1201.5885)
8. [Ceres Solver: Users](https://ceres-solver.readthedocs.io/latest/users.html)
9. [Implementing the Levenberg–Marquardt Algorithm on-line: A Sliding Window Approach with Early Stopping, ScienceDirect](https://www.sciencedirect.com/science/article/pii/S1474667017308492)
10. [Kenneth Levenberg (1944), original paper PDF, Frankford Arsenal](https://cs.uwaterloo.ca/~y328yu/classics/levenberg.pdf)
11. [GraphPad Prism Curve Fitting Guide: Who developed nonlinear regression?](https://www.graphpad.com/guides/prism/latest/curve-fitting/reg_who_developed_nonlinear_regres.htm)
12. [S. Mansour thesis (2015), citing Moré (1978), The Levenberg–Marquardt algorithm: Implementation and theory](https://arphymat.univ-rennes1.fr/publis/2015%20S.%20Mansour%20thesis.pdf)
13. [lmdif — MINPACK documentation, fortran-lang](https://fortran-lang.github.io/minpack/proc/lmdif.html)
14. [scipy.optimize.least_squares documentation](https://scipy.github.io/devdocs/reference/generated/scipy.optimize.least_squares.html)
15. [scipy.optimize.curve_fit documentation](https://cache-docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html)
16. [MATLAB lsqcurvefit documentation](https://www.mathworks.com/help/optim/ug/lsqcurvefit.html)
17. [MATLAB Least-Squares (Model Fitting) Algorithms](https://www.mathworks.com/help/optim/ug/least-squares-model-fitting-algorithms.html)
18. [Ceres Solver: Solving FAQs](https://ceres-solver.readthedocs.io/latest/solving_faqs.html)
19. [A stochastic Levenberg–Marquardt method using random models with complexity results. arXiv:1807.02176](https://arxiv.org/abs/1807.02176)
20. [Riemannian Levenberg–Marquardt Method with Global and Local Convergence Properties. arXiv:2210.00253](https://arxiv.org/abs/2210.00253)
21. [A Levenberg–Marquardt Method for Nonsmooth Regularized Least Squares. arXiv:2301.02347](https://arxiv.org/abs/2301.02347)
22. [Subspace Levenberg–Marquardt Algorithms in Training Neural Networks. arXiv:2609.00789](https://arxiv.org/abs/2609.00789)
23. [Fairbank & Alonso (2012). Efficient Calculation of the Gauss–Newton Approximation of the Hessian Matrix in Neural Networks. Neural Computation 24(3)](https://openaccess.city.ac.uk/id/eprint/4369/)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Regression analysis

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/levenberg-marquardt-algorithm

English original: https://www.edgepedia.org/levenberg-marquardt-algorithm
