Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tensorflow tf.hessians只打印对角线_Python_Tensorflow - Fatal编程技术网

Python Tensorflow tf.hessians只打印对角线

Python Tensorflow tf.hessians只打印对角线,python,tensorflow,Python,Tensorflow,定义一系列变量 a_v = tf.Variable([20.2], tf.float32) a_s = tf.Variable([18.0], tf.float32) ... 用给定的损失函数“loss”训练模型,然后计算上述变量的Hessian hess = tf.hessians( loss , [a_v,...] ) 对给定Hessian的评估 sess.run( hess, feed_dict= ... ) 只得到Hessian矩阵的对角线部分,而不是整个Hessian矩阵 从理

定义一系列变量

a_v = tf.Variable([20.2], tf.float32)
a_s = tf.Variable([18.0], tf.float32)
...
用给定的损失函数“loss”训练模型,然后计算上述变量的Hessian

hess = tf.hessians( loss ,  [a_v,...] )
对给定Hessian的评估

sess.run( hess, feed_dict= ... )
只得到Hessian矩阵的对角线部分,而不是整个Hessian矩阵


从理论上讲,该函数应支持“支持根据(一系列)一维张量计算Hessian值”。

我认为该函数在
xs
中计算Hessian w.r.t每个
x
。如果你想得到矩阵,可以使用两次
tf.gradient()
,虽然它会消耗大量内存。我用tf.gradient()做了一个函数,但效率非常低。考虑到Hessian在统计学中的重要性,tensorflow中没有内在函数对我来说似乎很奇怪。如何计算tf变量估计的误差和损失函数的刚度?