python - 如何在 Tensorflow 中进行列求和?

标签 python numpy tensorflow

Tensorflow 中以下内容的等价物是什么?

np.sum(A, axis=1)

最佳答案

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

关于python - 如何在 Tensorflow 中进行列求和?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35689671/

相关文章:

python - Pandas 按年分组,按销售列排名,在具有重复数据的数据框中

python - Numpy 图像数组根据二进制类别设置像素维度值

tensorflow - Keras VAE 的输入尺寸不正确

tensorflow - 带有 train_on_batch 的优化器?

python - 我有 10000 个矢量形式的图像,如何将其转换为我的卷积神经网络?

python - 如何使用 prefetch_related 获取 admin list_display 中自定义列的相关模型?

python - 将 CSV 数据读取为标题和值对

python - 在 Windows 10 上运行 python 脚本

python - 设置一种特定的日期类型以在 genfromtxt 中读取

python - 使用 MatplotLib Python 实现革命