快捷方式

torch.lu_solve

torch.lu_solve(b, LU_data, LU_pivots, *, out=None) Tensor

返回線性系統 Ax=bAx = b 的 LU 解,使用來自 lu_factor() 的 A 的部分樞軸 LU 分解。

此函式支援 floatdoublecfloatcdouble 的 dtypes 作為 input

警告

torch.lu_solve() 已棄用,建議使用 torch.linalg.lu_solve()torch.lu_solve() 將在未來的 PyTorch 版本中移除。 X = torch.lu_solve(B, LU, pivots) 應替換為

X = linalg.lu_solve(LU, pivots, B)
參數
  • b (Tensor) – 大小為 (,m,k)(*, m, k) 的 RHS 張量,其中 * 是零或多個批次維度。

  • LU_data (Tensor) – 來自 lu_factor() 的 A 的樞軸 LU 分解,大小為 (,m,m)(*, m, m),其中 * 是零或多個批次維度。

  • LU_pivots (IntTensor) – 來自 lu_factor() 的 LU 分解的樞軸,大小為 (,m)(*, m),其中 * 是零或多個批次維度。 LU_pivots 的批次維度必須等於 LU_data 的批次維度。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> A = torch.randn(2, 3, 3)
>>> b = torch.randn(2, 3, 1)
>>> LU, pivots = torch.linalg.lu_factor(A)
>>> x = torch.lu_solve(b, LU, pivots)
>>> torch.dist(A @ x, b)
tensor(1.00000e-07 *
       2.8312)

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學課程

取得初學者和進階開發人員的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得問題解答

檢視資源