反轉可變長度切片。
用法
tf.raw_ops.ReverseSequence(
input, seq_lengths, seq_dim, batch_dim=0, name=None
)參數
-
input一個Tensor。要反轉的輸入。 -
seq_lengths一個Tensor。必須是以下類型之一:int32,int64。長度為input.dims(batch_dim)和max(seq_lengths) <= input.dims(seq_dim)的一維 -
seq_dim一個int。部分反轉的維度。 -
batch_dim可選的int。默認為0。執行衝銷的維度。 -
name操作的名稱(可選)。
返回
-
一個
Tensor。具有與input相同的類型。
此操作首先沿維度 batch_dim 切片 input ,並且對於每個切片 i ,沿維度 seq_dim 反轉第一個 seq_lengths[i] 元素。
seq_lengths 的元素必須服從 seq_lengths[i] <= input.dims[seq_dim] ,並且 seq_lengths 必須是長度為 input.dims[batch_dim] 的向量。
沿維度 batch_dim 的輸出切片 i 然後由輸入切片 i 給出,沿維度 seq_dim 的第一個 seq_lengths[i] 切片反轉。
例如:
# Given this:
batch_dim = 0
seq_dim = 1
input.dims = (4, 8, ...)
seq_lengths = [7, 2, 3, 5]
# then slices of input are reversed on seq_dim, but only up to seq_lengths:
output[0, 0:7,:, ...] = input[0, 7:0:-1,:, ...]
output[1, 0:2,:, ...] = input[1, 2:0:-1,:, ...]
output[2, 0:3,:, ...] = input[2, 3:0:-1,:, ...]
output[3, 0:5,:, ...] = input[3, 5:0:-1,:, ...]
# while entries past seq_lens are copied through:
output[0, 7:,:, ...] = input[0, 7:,:, ...]
output[1, 2:,:, ...] = input[1, 2:,:, ...]
output[2, 3:,:, ...] = input[2, 3:,:, ...]
output[3, 2:,:, ...] = input[3, 2:,:, ...]
相反,如果:
# Given this:
batch_dim = 2
seq_dim = 0
input.dims = (8, ?, 4, ...)
seq_lengths = [7, 2, 3, 5]
# then slices of input are reversed on seq_dim, but only up to seq_lengths:
output[0:7,:, 0,:, ...] = input[7:0:-1,:, 0,:, ...]
output[0:2,:, 1,:, ...] = input[2:0:-1,:, 1,:, ...]
output[0:3,:, 2,:, ...] = input[3:0:-1,:, 2,:, ...]
output[0:5,:, 3,:, ...] = input[5:0:-1,:, 3,:, ...]
# while entries past seq_lens are copied through:
output[7:,:, 0,:, ...] = input[7:,:, 0,:, ...]
output[2:,:, 1,:, ...] = input[2:,:, 1,:, ...]
output[3:,:, 2,:, ...] = input[3:,:, 2,:, ...]
output[2:,:, 3,:, ...] = input[2:,:, 3,:, ...]
相關用法
- Python tf.raw_ops.ReverseV2用法及代碼示例
- Python tf.raw_ops.Reverse用法及代碼示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代碼示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代碼示例
- Python tf.raw_ops.ResourceScatterMul用法及代碼示例
- Python tf.raw_ops.ReduceJoin用法及代碼示例
- Python tf.raw_ops.ResourceScatterAdd用法及代碼示例
- Python tf.raw_ops.ResourceScatterMax用法及代碼示例
- Python tf.raw_ops.ResourceScatterMin用法及代碼示例
- Python tf.raw_ops.Real用法及代碼示例
- Python tf.raw_ops.Relu用法及代碼示例
- Python tf.raw_ops.ResourceGather用法及代碼示例
- Python tf.raw_ops.Reshape用法及代碼示例
- Python tf.raw_ops.ResourceScatterNdAdd用法及代碼示例
- Python tf.raw_ops.ResourceScatterNdUpdate用法及代碼示例
- Python tf.raw_ops.ResourceScatterSub用法及代碼示例
- Python tf.raw_ops.ResourceScatterUpdate用法及代碼示例
- Python tf.raw_ops.ResourceScatterDiv用法及代碼示例
- Python tf.raw_ops.RegexFullMatch用法及代碼示例
- Python tf.raw_ops.RaggedGather用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.raw_ops.ReverseSequence。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
