矩阵的 qr 分解

qr decomposition of a matrix

我想计算矩阵的 qr 分解 这是我的代码

const a = tf.tensor([1, 2, 3, 4], [2, 2]);
a.print()
const [b, c] = tf.qr(a)
b.print()

但它抛出以下错误

tf.qr is not a function or its return value is not iterable

文档不清楚tf.qr and tf.gramSchmidt. You need to use tf.linalg.qr and tf.linalg.gramSchmidt instead as you can see in the unit test code here

const [b, c] = tf.linalg.qr(a)

const a = tf.tensor([1, 2, 3, 4], [2, 2]);
a.print()
const [b, c] = tf.linalg.qr(a)
b.print()
<html>
  <head>
    <!-- Load TensorFlow.js -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tensorflow/0.12.4/tf.js"> </script>
  </head>

  <body>
  </body>
</html>