【发布时间】:2017-12-01 06:36:06
【问题描述】:
我正在尝试使用 PR 中添加的“高级”、numpy 样式切片,但是我遇到了 same issue as the user here:
ValueError: Shape must be rank 1 but is rank 2 for 'strided_slice_15' (op: 'StridedSlice') with input shapes: [3,2], [1,2], [1,2], [1].
也就是说,我想做与这个 numpy 操作等效的操作(在 numpy 中工作):
A = np.array([[1,2],[3,4],[5,6]])
id_rows = np.array([0,2])
A[id_rows]
但是对于上述错误,这在 TF 中不起作用:
A = tf.constant([[1,2],[3,4],[5,6]])
id_rows = tf.constant([0,2])
A[id_rows]
【问题讨论】:
标签: tensorflow