捷徑

torch.cholesky_inverse

torch.cholesky_inverse(L, upper=False, *, out=None) Tensor

計算給定一個複數 Hermitian 矩陣或實數對稱正定矩陣的 Cholesky 分解的逆矩陣。

AA 為複數 Hermitian 矩陣或實數對稱正定矩陣,LL 為其 Cholesky 分解,使得

A=LLHA = LL^{\text{H}}

其中 LHL^{\text{H}}LL 是複數時是共軛轉置,在 LL 是實數值時是轉置。

計算逆矩陣 A1A^{-1}

支援 float、double、cfloat 和 cdouble 資料類型輸入。 也支援批次的矩陣,並且如果 AA 是一個矩陣批次,則輸出具有相同的批次維度。

參數
  • L (Tensor) – 形狀為 (*, n, n) 的張量,其中 * 是零個或多個批次維度,包含對稱或 Hermitian 正定矩陣的下三角或上三角 Cholesky 分解。

  • upper (bool, optional) – 標記,指示 LL 是下三角還是上三角。 預設值: False

關鍵字參數

out (Tensor, optional) – 輸出張量。 如果為 None 則忽略。 預設值: 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)

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources