我试图在TensorFlow中复制这个:
mat = np.matrix("1,2,3;4,5,6;7,8,9")
matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
mat[2]
matrix([[7, 8, 9]])
我得到这个错误:
X_batch = X_train[batch]
IndexError: only integers, slices (
:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
X_train
是batch_size x (other dimensions)
,batch
是随机值的一维张量。在
我试着从一个训练集中随机抽取一批(实际上我想弄清楚如何训练多个时期,question here),并认为索引的随机张量是一种方法,但这不起作用。在
我想我从这个类似的问题中找到了答案:Tensorflow: Using tf.slice to split the input
答案似乎是tf.gather,正是这样。在
相关问题 更多 >
编程相关推荐