如何在Tensorflow中进行列总和? [英] How to do a column sum in Tensorflow?
本文介绍了如何在Tensorflow中进行列总和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Tensorflow中的以下等效项是什么?
What is the equivalent of the following in Tensorflow?
np.sum(A, axis=1)
推荐答案
有tf.reduce_sum,它是执行此操作的更强大的工具.
There is tf.reduce_sum which is a bit more powerfull tool for doing so.
# '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
这篇关于如何在Tensorflow中进行列总和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文