Last active
January 18, 2018 22:36
-
-
Save zhuangh/6831ac69ffc70e0add7378c1c7764347 to your computer and use it in GitHub Desktop.
tensorflow lu ops related (test script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
w = np.array([[3,-1,-1], [-1,5.0,-1], [1, 0 ,10]]) | |
print(w) | |
W = tf.constant(w) | |
l, u, p, q = tf.lu(W) | |
pinv = tf.matrix_inverse(p) | |
qinv = tf.matrix_inverse(q) | |
a1 = tf.matmul(pinv, l) | |
a2 = tf.matmul(a1, u) | |
a = tf.matmul(a2, qinv) | |
with tf.Session() as sess: | |
print('Lu') | |
sess.run(l) | |
print('l\n', l.eval()) | |
print('u\n', u.eval()) | |
print('q\n', q.eval()) | |
print('r\n', r.eval()) | |
sess.run(a) | |
print('a\n', a.eval()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment