1. 程式人生 > >TF 錯誤:InvalidArgumentError (see above for traceback): Reduction axis 0 is empty in shape [ ]

TF 錯誤:InvalidArgumentError (see above for traceback): Reduction axis 0 is empty in shape [ ]

Tensorflow.python.framework.errors_impl.InvalidArgumentError: Reduction axis 0 is empty in shape [0,100]

[[Node: ArgMax = ArgMax[T=DT_DOUBLE, Tidx=DT_INT32, output_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Const, ArgMax/dimension)]]

原因:因為tf.argmax()中的陣列是個空陣列

a = tf.constant(np.zeros([0,100]))
b = tf.argmax(a, axis=0)
with tf.Session() as sess:
    print(b)
    #如果把下面一行遮蔽開啟,就會報錯
    # print(sess.run(b))