#axis 表示在哪个维度进行sum操作,不写代表所有维
#keep_dims 是否保留原始数据维度
reduce_sum(
    input_tensor,
    axis=None,
    keep_dims=False,
    name=None,
    reduction_indices=None
)

官方例子:

# 'x' is [[1, 1, 1]
#         [1, 1, 1]]
tf.reduce_sum(x) ==> 6
tf.reduce_sum(x, 0) ==> [2, 2, 2]
tf.reduce_sum(x, 1) ==> [3, 3]
tf.reduce_sum(x, 1, keep_dims=True) ==> [[3], [3]]
tf.reduce_sum(x, [0, 1]) ==> 6

 

posted on 2018-05-07 11:33  笨拙的忍者  阅读(264)  评论(0编辑  收藏  举报