1. 程式人生 > >tf.argmax(array, 1)函式用法

tf.argmax(array, 1)函式用法

除了知道返回是座標,還須記得:

tf.argmax(array, 1) 指的是 axis=1

tf.argmax(array)預設axis=0

 

import numpy as np
import tensorflow as tf 
c = np.array([[1,8,3],[4,5,6]]) 
d = np.array([[-1,2,0],[7,8,-9]]) 

f1 = tf.argmax(c,1)
f2 = tf.argmax(d,1)
f3 = tf.argmax(c) 
f4 = tf.argmin(d) 

with tf.Session() as sess: 
    print(sess.run(f1))
    print(sess.run(f2))
    print (sess.run(f3)) 
    print (sess.run(f4))

[1 2]
[1 1]
[1 0 1]
[0 0 1]