
原来想要是先这个变换,查了一下tensorflow还真有,但是看上去很少有人用所以记录一下
tf.roll(
input, shift, axis, name=None
)
在tf1里是
tf.manip.roll(
input,
shift,
axis
)
示例
# '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]]
参数介绍及参考:
https://tensorflow.google.cn/api_docs/python/tf/roll#args
本文介绍了TensorFlow中tf.roll函数的使用方法及其参数设置。该函数可以在指定轴上实现张量元素的循环移位操作,适用于多维数据处理。文章通过示例展示了不同情况下tf.roll函数的应用。
1030

被折叠的 条评论
为什么被折叠?



