Tensorflow切片运算符到strided_slice

时间:2017-11-08 19:10:18

标签: python tensorflow

我想访问张量的第一个通道,其形状为:[batch_size, img_width, img_height, channel_size]

目前我这样做:

ch1 = X[...,0]

但是我想给这个操作命名,所以我必须使用tf.strided_slice,但我真的不明白它是如何工作的。如何使用X[...,0]重写tf.strided_slice

1 个答案:

答案 0 :(得分:0)

tf.strided_slice(ch1,[0,0,0,0],[batch_size, img_width, img_height,1])

您需要使用tf.reshape来获得X[...,0]返回的完全相同的形状。