评价此页

torch.lobpcg#

torch.lobpcg(A, k=None, B=None, X=None, n=None, iK=None, niter=None, tol=None, largest=None, method=None, tracker=None, ortho_iparams=None, ortho_fparams=None, ortho_bparams=None)[source]#

Find the k largest (or smallest) eigenvalues and the corresponding eigenvectors of a symmetric positive definite generalized eigenvalue problem using matrix-free LOBPCG methods.

This function is a front-end to the following LOBPCG algorithms selectable via method argument

method=”basic” - the LOBPCG method introduced by Andrew Knyazev, see [Knyazev2001]. A less robust method, may fail when Cholesky is applied to singular input.

method=”ortho” - the LOBPCG method with orthogonal basis selection [StathopoulosEtal2002]. A robust method.

Supported inputs are dense, sparse, and batches of dense matrices.

注意

In general, the basic method spends least time per iteration. However, the robust methods converge much faster and are more stable. So, the usage of the basic method is generally not recommended but there exist cases where the usage of the basic method may be preferred.

警告

The backward method does not support sparse and complex inputs. It works only when B is not provided (i.e. B == None). We are actively working on extensions, and the details of the algorithms are going to be published promptly.

警告

虽然假设 A 是对称的,但 A.grad 并不是。为了确保 A.grad 是对称的,从而在一阶优化例程中 A - t * A.grad 是对称的,我们在运行 lobpcg 之前执行以下对称化映射:A -> (A + A.t()) / 2。此映射仅在 A 需要梯度时执行。

参数
  • A (Tensor) – 输入张量,大小为 (,m,m)(*, m, m)

  • B (Tensor, optional) – 输入张量,大小为 (,m,m)(*, m, m)。未指定时,B 被解释为单位矩阵。

  • X (tensor, optional) – 输入张量,大小为 (,m,n)(*, m, n),其中 k <= n <= m。指定时,它将用作特征向量的初始近似。X 必须是密集张量。

  • iK (tensor, optional) – 输入张量,大小为 (,m,m)(*, m, m)。指定时,它将用作预条件子。

  • k (integer, optional) – 所需的特征对的数量。默认为 XX 的列数(如果指定)或 1

  • n (integer, optional) – 如果未指定 XX,则 n 指定生成的特征向量随机近似的大小。 n 的默认值为 k。如果指定了 XX,则 n 的值(如果指定)必须是 XX 的列数。

  • tol (float, optional) – 停止准则的残差容差。默认为 feps ** 0.5,其中 feps 是给定输入张量 A 数据类型中最小的非零浮点数。

  • largest (bool, optional) – 如果为 True,则求解最大特征值的特征问题。否则,求解最小特征值的特征问题。默认为 True

  • method (str, optional) – 选择 LOBPCG 方法。请参阅上面函数的描述。默认为“ortho”。

  • niter (int, optional) – 最大迭代次数。达到此次数时,迭代过程将被强制停止,并返回特征对的当前近似值。对于无限迭代但直到收敛准则满足,请使用 -1

  • tracker (callable, optional) –

    用于跟踪迭代过程的函数。指定时,它将在每个迭代步骤调用,并将 LOBPCG 实例作为参数。LOBPCG 实例在以下属性中保存迭代过程的完整状态

    iparamsfparamsbparams – 分别是整数、浮点数和布尔值输入参数的字典

    ivarsfvarsbvarstvars – 分别是整数、浮点数、布尔值和 Tensor 值迭代变量的字典。

    ABiK – 输入 Tensor 参数。

    EXSR – 迭代 Tensor 变量。

    例如

    ivars[“istep”] – 当前迭代步骤 X – 特征向量的当前近似值 E – 特征值的当前近似值 R – 当前残差 ivars[“converged_count”] – 当前收敛的特征对数量 tvars[“rerr”] – 收敛准则的当前状态

    请注意,当 tracker 存储来自 LOBPCG 实例的 Tensor 对象时,它必须创建这些对象的副本。

    如果 tracker 设置 bvars[“force_stop”] = True,迭代过程将被强制停止。

  • ortho_iparams (dict, optional) – 使用 method=”ortho” 时 LOBPCG 算法的各种参数。

  • ortho_fparams (dict, optional) – 使用 method=”ortho” 时 LOBPCG 算法的各种参数。

  • ortho_bparams (dict, optional) – 使用 method=”ortho” 时 LOBPCG 算法的各种参数。

返回

特征值张量,大小为 (,k)(*, k)

X (Tensor): 特征向量张量,大小为 (,m,k)(*, m, k)

返回类型

E (Tensor)

参考文献

[Knyazev2001] Andrew V. Knyazev. (2001) Toward the Optimal Preconditioned Eigensolver: Locally Optimal Block Preconditioned Conjugate Gradient Method. SIAM J. Sci. Comput., 23(2), 517-541. (25 pages) https://epubs.siam.org/doi/abs/10.1137/S1064827500366124

[StathopoulosEtal2002] Andreas Stathopoulos and Kesheng Wu. (2002) A Block Orthogonalization Procedure with Constant Synchronization Requirements. SIAM J. Sci. Comput., 23(6), 2165-2182. (18 pages) https://epubs.siam.org/doi/10.1137/S1064827500370883

[DuerschEtal2018] Jed A. Duersch, Meiyue Shao, Chao Yang, Ming Gu. (2018) A Robust and Efficient Implementation of LOBPCG. SIAM J. Sci. Comput., 40(5), C655-C676. (22 pages) https://arxiv.org/abs/1704.07458