def test_qr(self):
   random_matrix = np.random.rand(10, 10)
   for non_negative_diagonal in [True, False]:
     q, r = decompositions.qr(tf, random_matrix, 1, non_negative_diagonal)
     self.assertAllClose(tf.tensordot(q, r, ([1], [0])), random_matrix)
Exemplo n.º 2
0
 def qr(self, tensor: Tensor, pivot_axis: int = -1,
        non_negative_diagonal: bool = False) -> Tuple[Tensor, Tensor]:
   return decompositions.qr(tf, tensor, pivot_axis, non_negative_diagonal)
 def test_expected_shapes_qr(self):
   val = tf.zeros((2, 3, 4, 5))
   for non_negative_diagonal in [True, False]:
     q, r = decompositions.qr(tf, val, 2, non_negative_diagonal)
     self.assertEqual(q.shape, (2, 3, 6))
     self.assertEqual(r.shape, (6, 4, 5))