1
我想用tensorflow.cholesky_solve来解决一个线性方程组,我得到了一些意想不到的结果。可能tensorflow cholesky_solve不一致?
我写了一个脚本来比较非常简单的线性系统的输出与简单矩阵求逆器,非基于cholesky的矩阵方程求解器tensorflow.matrix_solve和tensorflow.cholesky_solve
。
根据我对我所链接的文档的理解,这三种情况都应该产生单位矩阵除以2的解,但tensorflow.cholesky_solve
并不是这种情况。也许我误解了文档?
import tensorflow as tf
I = tf.eye(2, dtype=tf.float32)
X = 2 * tf.eye(2, dtype=tf.float32)
X_inv = tf.matrix_inverse(X)
X_solve = tf.matrix_solve(X, I)
X_chol_solve = tf.cholesky_solve(tf.cholesky(X), I)
with tf.Session() as sess:
for x in [X_inv, X_solve, X_chol_solve]:
print('{}:\n{}'.format(x.name, sess.run(x)))
print
产生输出:
MatrixInverse:0:
[[ 0.5 0. ]
[ 0. 0.5]]
MatrixSolve:0:
[[ 0.5 0. ]
[ 0. 0.5]]
cholesky_solve/MatrixTriangularSolve_1:0:
[[ 1. 0.]
[ 0. 1.]]
Process finished with exit code 0
我回答了你的问题吗? – MaxB