简体   繁体   English

scipy.optimize.least_squares,参数“jac”的线性运算符

[英]scipy.optimize.least_squares, LinearOperator for argument 'jac'

I'm trying to understand the documentation on the scipy.optimize.least_squares function:我试图了解scipy.optimize.least_squares function 上的文档:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html

The possibilities for inputs are a bit messy, and the documentation is not super clear on all of them.输入的可能性有点混乱,并且文档对所有这些都不是很清楚。 It says that the argument jac can be a callable returning a LinearOperator .它说参数jac可以是一个可调用的返回一个LinearOperator

  1. I suppose, the provided LinearOperator is supposed to represent the Jacobian as a linear operator mapping the variable shifts to the residual shifts.我想,提供的LinearOperator应该将雅可比表示为将变量偏移映射到残差偏移的线性算子。 Or is it the other way round?还是相反?

  2. Which operations do I need to implement for the LinearOperator ?我需要为LinearOperator实施哪些操作? Only matvec , or matmat as well?只有matvec还是matmat

  3. Does providing a LinearOperator instead of the full Jacobi matrix actually speed up anything?提供LinearOperator而不是完整的 Jacobi 矩阵实际上会加速任何事情吗? Or is the full matrix built from the operator anyways?还是无论如何都是从运算符构建的完整矩阵? (And yes, in my example, evaluating the LinearOperator is much faster than building the whole Jacobi matrix.) (是的,在我的示例中,评估LinearOperator比构建整个 Jacobi 矩阵要快得多。)

  1. least_squares expects Jacobian of original functions (the variable shifts to the value shifts). least_squares期望原始函数的雅可比行列式(变量转移到值转移)。 If you know Jacobian for residuals, you probably should switch to fmincon or other optimization routine and work with residuals.如果您知道雅可比的残差,您可能应该切换到fmincon或其他优化例程并使用残差。 One of the main advantages of least squares approach is the opportunity to efficiently talk on the language of original functions instead of residuals.最小二乘法的主要优点之一是有机会有效地讨论原始函数的语言而不是残差。
  2. least_squares invokes matmat , matvec , rmatvec , but LinearOperator itself can implement matmat from matvec , if only matvec is provided (and vice versa). matmat least_squares matvecrmatvec ,但LinearOperator本身可以从matvec实现matmat ,如果只提供matvec (反之亦然)。 But it cannot implement rmatvec without rmatvec or rmatmat .但如果没有rmatvecrmatmat rmatvec
  3. Most of the time only the result of J(x).T.dot(f) is needed and the full matrix is not held.大多数时候只需要J(x).T.dot(f)的结果,并且不保存完整的矩阵。 Yet I noticed some numerical difference between matrix and operators Jacobians.然而,我注意到矩阵和运算符 Jacobians 之间存在一些数值差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM