(self, dtype, shape, full_matrices)
| 67 | self.assertTrue(np.all(precision < 4800.0)) |
| 68 | |
| 69 | def _test(self, dtype, shape, full_matrices): |
| 70 | np.random.seed(1) |
| 71 | x_np = np.random.uniform( |
| 72 | low=-1.0, high=1.0, size=np.prod(shape)).reshape(shape).astype(dtype) |
| 73 | |
| 74 | with self.session() as sess: |
| 75 | x_tf = array_ops.placeholder(dtype) |
| 76 | with self.test_scope(): |
| 77 | q_tf, r_tf = linalg_ops.qr(x_tf, full_matrices=full_matrices) |
| 78 | q_tf_val, r_tf_val = sess.run([q_tf, r_tf], feed_dict={x_tf: x_np}) |
| 79 | |
| 80 | q_dims = q_tf_val.shape |
| 81 | np_q = np.ndarray(q_dims, dtype) |
| 82 | np_q_reshape = np.reshape(np_q, (-1, q_dims[-2], q_dims[-1])) |
| 83 | new_first_dim = np_q_reshape.shape[0] |
| 84 | |
| 85 | x_reshape = np.reshape(x_np, (-1, x_np.shape[-2], x_np.shape[-1])) |
| 86 | for i in range(new_first_dim): |
| 87 | if full_matrices: |
| 88 | np_q_reshape[i, :, :], _ = np.linalg.qr( |
| 89 | x_reshape[i, :, :], mode="complete") |
| 90 | else: |
| 91 | np_q_reshape[i, :, :], _ = np.linalg.qr( |
| 92 | x_reshape[i, :, :], mode="reduced") |
| 93 | np_q = np.reshape(np_q_reshape, q_dims) |
| 94 | self.CompareOrthogonal(np_q, q_tf_val, min(shape[-2:])) |
| 95 | self.CheckApproximation(x_np, q_tf_val, r_tf_val) |
| 96 | self.CheckUnitary(q_tf_val) |
| 97 | |
| 98 | SIZES = [1, 2, 5, 10, 32, 100, 300] |
| 99 | DTYPES = [np.float32] |
no test coverage detected