x = tf.Variable([[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
[1, 2, 3]], dtype=tf.float32)
print(tf.reduce_mean(x, axis=0)) # 每一列求平均
>>> tf.Tensor([1. 2. 3.], shape=(3,), dtype=float32)
print(tf.reduce_mean(x, axis=1)) # 每一行求平均
>>> tf.Tensor([2. 2. 2. 2.], shape=(4,), dtype=float32)
【tf】tf.reduce_mean
最新推荐文章于 2021-08-18 16:17:38 发布