【发布时间】:2017-10-23 02:06:18
【问题描述】:
有没有办法在 Tensorflow 中完成这种切片方法(使用 numpy 显示的示例)?
z = np.random.random((3,7,7,12))
x = z[...,[0,5]]
这样
x_hat = np.concatenate([z[...,[0]], z[...,[5]]], 3)
assert np.all(x == x_hat)
x.shape # (3, 7, 7, 2)
在 TensorFlow 中,这个操作
tfz = tf.constant(z)
i = np.array([0,5] dtype=np.int32)
tfx = tfz[...,i]
抛出错误
ValueError: Shapes must be equal rank, but are 0 and 1
From merging shape 0 with other shapes. for 'strided_slice/stack_1' (op: 'Pack') with input shapes: [], [2].
【问题讨论】:
标签: python tensorflow