Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.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 tf.梯度-输出尺寸_Python_Tensorflow_Gradient_Dimensions - Fatal编程技术网

Python tf.梯度-输出尺寸

Python tf.梯度-输出尺寸,python,tensorflow,gradient,dimensions,Python,Tensorflow,Gradient,Dimensions,这是我的密码: import tensorflow as tf tf.reset_default_graph() x = tf.placeholder(tf.float32, [None, 3],name='x') W_1 = tf.get_variable('W_1', [3,3], dtype = tf.float32, initializer=tf.constant_initializer(1.0)) layer_out = tf.matmul(x, W_1, name = 'layer_

这是我的密码:

import tensorflow as tf
tf.reset_default_graph()
x = tf.placeholder(tf.float32, [None, 3],name='x')
W_1 = tf.get_variable('W_1', [3,3], dtype = tf.float32, initializer=tf.constant_initializer(1.0))
layer_out = tf.matmul(x, W_1, name = 'layer_out')
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run([tf.gradients(layer_out, [x])], feed_dict = {x: np.array([[1,7,5]])} )
它返回:

[[array([[3., 3., 3.]], dtype=float32)]]
我希望得到3乘3矩阵或根据
tf.gradients
docs dim 3的列表,每个列表条目有3个元素

我错过了什么

更新:

我在文档中看到

但为什么求和?如何得到雅可比矩阵的所有项

A list of sum(dy/dx) for each x in xs