torch.cholesky_inverse
- torch.cholesky_inverse(L, upper=False, *, out=None) → Tensor
-
根据其 Cholesky 分解计算复 Hermite 矩阵或实对称正定矩阵的逆。
设$A$是一个复赫mitte矩阵或实对称正定矩阵,$L$是它的Cholesky分解,满足:
$A = LL^{\text{H}}$其中$L^{\text{H}}$ 是当$L$ 为复数时的共轭转置,当$L$ 为实数值时则是普通转置。
计算矩阵 $A^{-1}$ 的逆矩阵。
支持浮点型、双精度型、复数浮点型和复数双精度型数据类型的输入。也支持矩阵的批量处理,如果$A$是一组矩阵,则输出将具有相同的批处理维度。
- 参数
- 关键字参数
-
out (Tensor, optional) – 输出张量。默认为None,若未指定则忽略。
示例:
>>> A = torch.randn(3, 3) >>> A = A @ A.T + torch.eye(3) * 1e-3 # Creates a symmetric positive-definite matrix >>> L = torch.linalg.cholesky(A) # Extract Cholesky decomposition >>> torch.cholesky_inverse(L) tensor([[ 1.9314, 1.2251, -0.0889], [ 1.2251, 2.4439, 0.2122], [-0.0889, 0.2122, 0.1412]]) >>> A.inverse() tensor([[ 1.9314, 1.2251, -0.0889], [ 1.2251, 2.4439, 0.2122], [-0.0889, 0.2122, 0.1412]]) >>> A = torch.randn(3, 2, 2, dtype=torch.complex64) >>> A = A @ A.mH + torch.eye(2) * 1e-3 # Batch of Hermitian positive-definite matrices >>> L = torch.linalg.cholesky(A) >>> torch.dist(torch.inverse(A), torch.cholesky_inverse(L)) tensor(5.6358e-7)