【问题标题】:Undesired output with tf.reduce_sum()tf.reduce_sum() 的非期望输出
【发布时间】:2019-09-06 05:29:04
【问题描述】:

使用 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>

【问题讨论】:

    标签: pandas numpy tensorflow tensorboard


    【解决方案1】:

    如果要显示,需要在会话中并使用eval()

    import tensorflow as tf
    sess = tf.InteractiveSession()
    
    x = tf.constant([[1,1,1],[1,1,1]])
    tf.reduce_sum(x,0).eval()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多