torch.lu_solve¶
- torch.lu_solve(b, LU_data, LU_pivots, *, out=None) Tensor ¶
返回線性系統 的 LU 解,使用來自
lu_factor()
的 A 的部分樞軸 LU 分解。此函式支援
float
、double
、cfloat
和cdouble
的 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) – 大小為 的 RHS 張量,其中 是零或多個批次維度。
LU_data (Tensor) – 來自
lu_factor()
的 A 的樞軸 LU 分解,大小為 ,其中 是零或多個批次維度。LU_pivots (IntTensor) – 來自
lu_factor()
的 LU 分解的樞軸,大小為 ,其中 是零或多個批次維度。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)