tf.reduce_sum() 的意外输出
Undesired output with tf.reduce_sum()
使用 tensorflow reduce_sum 但得到不需要的输出。
我正在尝试计算以下内容:
x = tf.constant([[1,1,1],[1,1,1]])
tf.reduce_sum(x,0)
expected output = [2, 2, 2]
actual output = <tf.Tensor 'Sum:0' shape=() dtype=int32>
如果要显示,需要在会话中使用eval()
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.constant([[1,1,1],[1,1,1]])
tf.reduce_sum(x,0).eval()
使用 tensorflow reduce_sum 但得到不需要的输出。 我正在尝试计算以下内容:
x = tf.constant([[1,1,1],[1,1,1]])
tf.reduce_sum(x,0)
expected output = [2, 2, 2]
actual output = <tf.Tensor 'Sum:0' shape=() dtype=int32>
如果要显示,需要在会话中使用eval()
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.constant([[1,1,1],[1,1,1]])
tf.reduce_sum(x,0).eval()