當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tf.linalg.cholesky_solve用法及代碼示例

在給定 Cholesky 分解的情況下,求解線性 eqns A X = RHS 係統。

用法

tf.linalg.cholesky_solve(
    chol, rhs, name=None
)

參數

  • chol 一個Tensor。必須是 float32float64 ,形狀是 [..., M, M]A 的 Cholesky 分解,例如chol = tf.linalg.cholesky(A) 。因此,僅使用chol 的最後兩個維度的下三角形部分(包括對角線)。嚴格的上半部分假定為零且未被訪問。
  • rhs A Tensor ,與 chol 相同類型,形狀為 [..., M, K]
  • name 給這個 Op 的名稱。默認為 cholesky_solve

返回

  • A x = rhs 的解決方案,形狀 [..., M, K]

具體來說,從 A X = RHS 返回 X ,其中 A = L L^T , Lchol arg 並且 RHSrhs arg。

# Solve 10 separate 2x2 linear systems:
A = ... # shape 10 x 2 x 2
RHS = ... # shape 10 x 2 x 1
chol = tf.linalg.cholesky(A)  # shape 10 x 2 x 2
X = tf.linalg.cholesky_solve(chol, RHS)  # shape 10 x 2 x 1
# tf.matmul(A, X) ~ RHS
X[3,:, 0]  # Solution to the linear system A[3,:,:] x = RHS[3,:, 0]

# Solve five linear systems (K = 5) for every member of the length 10 batch.
A = ... # shape 10 x 2 x 2
RHS = ... # shape 10 x 2 x 5
...
X[3,:, 2]  # Solution to the linear system A[3,:,:] x = RHS[3,:, 2]

相關用法


注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.linalg.cholesky_solve。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。