axis
- axis = 0 不仅可以表示按行操作
eg: 相加合并成一行import tensorflow as tf x = tf.constant([[1,2,3], [1,2,3]]) with tf.Session() as sess: print(tf.reduce_sum(x, axis=0).eval()) # [2 4 6] - axis = 0 还可以表示竖直方向
import tensorflow as tf import numpy as np test = np.array([[1, 2, 3], [2, 3, 4]]) t = tf.argmax(test, axis=0) with tf.Session() as sess: print(t.eval()) # [1 1 1]
argmax
- 返回指定方向上最大值序号
感觉:
tensorflow的接口,总能嗅到广播的味道

本文详细解析了在TensorFlow中使用axis参数进行数据操作的方法,包括如何通过axis=0进行行方向的操作,如数据的相加合并和最大值索引的获取。并通过具体示例展示了如何利用tf.reduce_sum和tf.argmax函数实现这些操作。

1万+

被折叠的 条评论
为什么被折叠?



