Ejemplo n.º 1
0
    def testSvd(self):
        a = getTestMatrix()
        with self.test_session():
            tf_ans_u, tf_ans_s, tf_ans_v = tf.matrix_decomp_svd(a)
            tf_ans_u = tf_ans_u.eval()
            tf_ans_s = tf_ans_s.eval()
            tf_ans_v = tf_ans_v.eval()
        full_s = np.diag(tf_ans_s)

        np_reconstr = np.dot(np.dot(tf_ans_u, full_s), np.transpose(tf_ans_v))
        self.assertAllClose(a, np_reconstr, atol=1e-5, rtol=1e-5)
Ejemplo n.º 2
0
    def testSvd(self):
        a = getTestMatrix()
        with self.test_session():
            tf_ans_u, tf_ans_s, tf_ans_v = tf.matrix_decomp_svd(a)
            tf_ans_u = tf_ans_u.eval()
            tf_ans_s = tf_ans_s.eval()
            tf_ans_v = tf_ans_v.eval()
        full_s = np.diag(tf_ans_s)

        np_reconstr = np.dot(np.dot(tf_ans_u,  full_s), np.transpose(tf_ans_v))
        self.assertAllClose(a, np_reconstr, atol=1e-5, rtol=1e-5)
Ejemplo n.º 3
0
    def testSvdV(self):
        a = getTestMatrix()
        print("Test sdv V")
        np_ans = numpyTestSvdV(a)
        print("np_ans:")
        print(np_ans)

        with self.test_session():
            _, _, tf_ans = tf.matrix_decomp_svd(a)
            tf_ans = tf_ans.eval()
            print("tf_ans")
            print(tf_ans)
Ejemplo n.º 4
0
    def testSvdV(self):
        a = getTestMatrix()
        print("Test sdv V")
        np_ans = numpyTestSvdV(a)
        print("np_ans:")
        print(np_ans)

        with self.test_session():
            _, _, tf_ans = tf.matrix_decomp_svd(a)
            tf_ans = tf_ans.eval()
            print("tf_ans")
            print(tf_ans)
Ejemplo n.º 5
0
    def testSvdS(self):
        a = getTestMatrix()
        print("Test sdv S")
        np_ans = numpyTestSvdS(a)
        print("np_ans:")
        print(np_ans)

        with self.test_session():
            _, tf_ans, _ = tf.matrix_decomp_svd(a)
            tf_ans = tf_ans.eval()
            print("tf_ans")
            print(tf_ans)

        self.assertAllClose(np_ans, tf_ans, atol=1e-5, rtol=1e-5)
Ejemplo n.º 6
0
    def testSvdS(self):
        a = getTestMatrix()
        print("Test sdv S")
        np_ans = numpyTestSvdS(a)
        print("np_ans:")
        print(np_ans)

        with self.test_session():
            _, tf_ans, _ = tf.matrix_decomp_svd(a)
            tf_ans = tf_ans.eval()
            print("tf_ans")
            print(tf_ans)

        self.assertAllClose(np_ans, tf_ans, atol=1e-5, rtol=1e-5)