我在TensorFlow上被切片操作困住了。我要做的就是这样麻木,
>>> a = np.arange(24).reshape((4,6))
>>> a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17],
[18, 19, 20, 21, 22, 23]])
>>> print(a[[2,3],[0,1]])
array([12, 19])
然而,在TensorFlow中,
>>> a = tf.Variable(np.arange(24).reshape((4,6)))
>>> with tf.Session() as sess:
... sess.run(tf.global_variables_initializer())
... print(sess.run(a[[2,3],[0,1]]))
我有个错误说
TypeError: can only concatenate list (not "int") to list
. 有没有办法在TensorFlow中执行此切片?
谢谢您。