mar*_*oxe 16 python numpy tensorflow
Tensorflow中的以下内容相当于什么?
np.sum(A, axis=1)
Run Code Online (Sandbox Code Playgroud)
lej*_*lot 34
有tf.reduce_sum这是一个更强大的工具.
# '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
Run Code Online (Sandbox Code Playgroud)