沿軸滾動張量的元素。
用法
tf.roll(
input, shift, axis, name=None
)
參數
-
input
一個Tensor
。 -
shift
一個Tensor
。必須是以下類型之一:int32
,int64
。維度必須是 0-D 或 1-D。shift[i]
指定元素沿axis[i]
指定的維度正向(朝向更大的索引)移動的位置數。負位移將沿相反方向滾動元素。 -
axis
一個Tensor
。必須是以下類型之一:int32
,int64
。維度必須是 0-D 或 1-D。axis[i]
指定移位shift[i]
應該發生的維度。如果多次引用同一軸,則該軸的總位移將是屬於該軸的所有位移的總和。 -
name
操作的名稱(可選)。
返回
-
一個
Tensor
。具有與input
相同的類型。
元素沿 axis
的維度通過 shift
的偏移量正向移動(朝向更大的索引)。負的shift
值將沿相反方向移動元素。滾動通過最後一個位置的元素將環繞到第一個位置,反之亦然。可以指定沿多個軸的多個移位。
例如:
# 't' is [0, 1, 2, 3, 4]
roll(t, shift=2, axis=0) ==> [3, 4, 0, 1, 2]
# shifting along multiple dimensions
# 't' is [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
roll(t, shift=[1, -2], axis=[0, 1]) ==> [[7, 8, 9, 5, 6], [2, 3, 4, 0, 1]]
# shifting along the same axis multiple times
# 't' is [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
roll(t, shift=[2, -3], axis=[1, 1]) ==> [[1, 2, 3, 4, 0], [6, 7, 8, 9, 5]]
相關用法
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.Bitcast用法及代碼示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代碼示例
- Python tf.raw_ops.BatchMatMul用法及代碼示例
- Python tf.raw_ops.OneHot用法及代碼示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代碼示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代碼示例
- Python tf.raw_ops.GatherV2用法及代碼示例
- Python tf.raw_ops.Expm1用法及代碼示例
- Python tf.range用法及代碼示例
- Python tf.raw_ops.BitwiseAnd用法及代碼示例
- Python tf.raw_ops.UniqueWithCounts用法及代碼示例
- Python tf.raw_ops.DecodeGif用法及代碼示例
- Python tf.random.truncated_normal用法及代碼示例
- Python tf.raw_ops.Size用法及代碼示例
- Python tf.raw_ops.ScatterUpdate用法及代碼示例
- Python tf.raw_ops.ParallelConcat用法及代碼示例
- Python tf.raw_ops.ScatterNdUpdate用法及代碼示例
- Python tf.raw_ops.BatchToSpaceND用法及代碼示例
- Python tf.ragged.cross用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.roll。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。