TensorFlow cholesky 分解 [英] TensorFlow cholesky decomposition

查看:79
本文介绍了TensorFlow cholesky 分解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过阅读 TensorFlow 文档,我看到有一种方法可以计算 Cholesky 分解一个方阵.但是,通常当我想使用 Cholesky 分解时,我这样做是为了解决直接矩阵求逆可能不稳定的线性系统.

因此,我正在寻找一种类似于 Scipy.有谁知道这是否存在于 TensorFlow 中,或者是否可以通过某种方式将其合并?

解决方案

更新 (2017/04/23)

TensorFlow 现在有许多线性代数运算.例如,结帐 tf.cholesky_solvetf.matrix_solve_ls, tf.matrix_solvetf.qrtf.svd 等.当然,下面的原始答案也可能有帮助.

原创matrix_inverse 是否满足您的需求?它使用 Cholesky 或 LU 分解,具体取决于输入.例如,

<预><代码>>>>将张量流导入为 tf>>>x = [[1.,1.],[-2.,3.],[1.,-1.]]>>>y = [[-1.],[-8.],[3.]]>>>a = tf.matrix_inverse(tf.matmul(x, x, transpose_a=True))>>>b = tf.matmul(tf.matmul(a, x, transpose_b=True), y)>>>使用 tf.Session():... 打印 b.eval()...[[1.][-2.]]

From reading the TensorFlow documentation I see that there is a method for computing the Cholesky decomposition of a square matrix. However, usually when I want to use Cholesky decomposition, I do it for the purposes of solving a linear system where direct matrix inversion might be unstable.

Therefore, I am looking for a method similar to the one implemented in Scipy. Does anyone know if this exists in TensorFlow or if there is a way it could be incorporated?

解决方案

Update (2017/04/23)

TensorFlow now has many linear algebra operations. For instance, checkout tf.cholesky_solve, tf.matrix_solve_ls, tf.matrix_solve, tf.qr, tf.svd, etc. Of course, the original answer below may be helpful as well.

Original Does matrix_inverse do what you need? It uses Cholesky or LU Decomposition, depending on the input. For example,

>>> import tensorflow as tf
>>> x = [[1.,1.],[-2.,3.],[1.,-1.]]
>>> y = [[-1.],[-8.],[3.]]
>>> a = tf.matrix_inverse(tf.matmul(x, x, transpose_a=True))
>>> b = tf.matmul(tf.matmul(a, x, transpose_b=True), y)
>>> with tf.Session():
...   print b.eval()
... 
[[ 1.]
 [-2.]]

这篇关于TensorFlow cholesky 分解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆