-1
使用Python中TensorFlow,我有以下代碼:矩陣M1由tf.inverse(M1)乘以不會產生單位矩陣
sess = tf.InteractiveSession() # so I can eval()
t1 = tf.convert_to_tensor([[1,4,5],[34,5,1],[53,1,4]],dtype=tensorflow.float32)
t1.eval()
OUTPUT>> array([[ 1., 4., 5.],
[ 34., 5., 1.],
[ 53., 1., 4.]], dtype=float32)
# so far, so good!
t1_inverse = tf.matrix_inverse(t1)
t1_inverse.eval()
OUTPUT>> array([[-0.01294278, 0.00749319, 0.01430518],
[ 0.05653951, 0.17779292, -0.11512262],
[ 0.15735695, -0.14373296, 0.08923706]], dtype=float32)
# I'm not a math whiz but this looks like an inverted matrix to me!
(t1*t1_inverse).eval() # should yield identity matrix, but..
OUTPUT>> array([[-0.01294278, 0.02997275, 0.07152588],
[ 1.92234337, 0.88896459, -0.11512262],
[ 8.33991814, -0.14373296, 0.35694823]], dtype=float32)
所以我的問題是,爲什麼矩陣T1乘以它的逆不產生單位矩陣,或[[1,0,0],[0,1,0],[0,0,1]]?
是的,看起來t1 * t2(或等同於tf.matrix_multiply(t1,t2))是廣播乘法。謝謝! – zannorman