下面代码为什么得到这样的输出?
import tensorflow as tf
import numpy as np
test= np.array([[[1,2],[2,3]],[[4,5],[6,7]],[[3,9],[4,6]],[[6,3],[4,8]] ])
print("**********************")
print(test)
print(test.shape)
print("***********************")
x0 = tf.argmax(test,0)
y0 = tf.Session().run(x0)
x1 = tf.argmax(test, 1)
y1 = tf.Session().run(x1)
x2 = tf.argmax(test, 2)
y2 = tf.Session().run(x2)
print("xxxxxxxxxxxxx")
print(y0)
print("xxxxxxxxxxxxx")
print(y1)
print("xxxxxxxxxxxxx")
print(y2)
输出:
**********************
[[[1 2]
[2 3]]
[[4 5]
[6 7]]
[[3 9]
[4 6]]
[[6 3]
[4 8]]]
(4, 2, 2)
***********************
xxxxxxxxxxxxx
[[3 2]
[1 3]]
xxxxxxxxxxxxx
[[1 1]
[1 1]
[1 0]
[0 1]]
xxxxxxxxxxxxx
[[1 1]
[1 1]
[1 1]
[0 1]]
Process finished with exit code 0
def argmax(self, axis=None, fill_value=None, out=None):
返回沿着某个维度最大值的位置
Returns array of indices of the maximum values along the given axis.
Masked values are treated as if they had the value fill_value.
Parameters
----------
axis : {None, integer}
If None, the index is into the flattened array, otherwise along
the specified axis
fill_value : {var}, optional
Value used to fill in the masked values. If None, the output of
maximum_fill_value(self._data) is used instead.
out : {None, array}, optional
Array into which the result can be placed. Its type is preserved
and it must be of the right shape to hold the output.
Returns