tf.argmax(array, axis)

tf.argmax(array, axis)

返回值,最大值的索引,axis取0或者1.

test = np.array([[1, 2, 3], [2, 3, 4], [5, 4, 3], [8, 7, 2]])
np.argmax(test, 0)   #输出:array([3, 3, 1]
np.argmax(test, 1)   #输出:array([2, 2, 0, 0]

在axis为1的时候,为横向比较。

test = np.array([[1, 2, 3], [2, 3, 4], [5, 4, 3], [8, 7, 2]])
              max     max  max,index=0 
            index is 2 index is2      max.index=0
np.argmax(test, 1)   #输出:array([2, 2, 0, 0]

在axis为0的时候是,纵向比较。

            test = np.array([[1, 2, 3],
                             [2, 3, 4],  max, index is 1
                             [5, 4, 3], 
                 max, index is 3 [8, 7, 2]])            
                        max,index=3                         
np.argmax(test, 0)    #输出:array([3, 3, 1]

参考这里:https://blog.csdn.net/qq575379110/article/details/70538051

原文地址:https://www.cnblogs.com/smartmsl/p/8821272.html