Ref:
https://www.tensorflow.org/api_docs/python/tf/slice
https://www.tensorflow.org/api_docs/python/tf/slice
tf.slice
input_
: ATensor
.begin
: Anint32
orint64
Tensor
.size
: Anint32
orint64
Tensor
.name
: A name for the operation (optional).
t = tf.constant([[[1, 1, 1], [2, 2, 2]],
[[3, 3, 3], [4, 4, 4]],
[[5, 5, 5], [6, 6, 6]]])
tf.slice(t, [1, 0, 0], [1, 1, 3]) # [[[3, 3, 3]]]
tf.slice(t, [1, 0, 0], [1, 2, 3]) # [[[3, 3, 3],
# [4, 4, 4]]]
tf.slice(t, [1, 0, 0], [2, 1, 3]) # [[[3, 3, 3]],
# [[5, 5, 5]]]
留言
張貼留言