maxframe.tensor.rollaxis#

maxframe.tensor.rollaxis(tensor, axis, start=0)[源代码]#

将指定轴向后滚动,直到它位于给定位置。

此函数为了向后兼容仍然支持,但建议使用 moveaxis

参数:
  • a (Tensor) -- 输入张量。

  • axis (int) -- 要向后滚动的轴。其他轴的位置相对于彼此不会改变。

  • start (int, optional) -- 轴会一直滚动到位于此位置之前。默认值为 0,表示进行“完整”滚动。

返回:

res -- 总是返回 a 的视图。

返回类型:

Tensor

参见

moveaxis

将数组轴移动到新位置。

roll

沿给定轴将数组元素滚动指定位置数。

示例

>>> import maxframe.tensor as mt
>>> a = mt.ones((3,4,5,6))
>>> mt.rollaxis(a, 3, 1).shape
(3, 6, 4, 5)
>>> mt.rollaxis(a, 2).shape
(5, 3, 4, 6)
>>> mt.rollaxis(a, 1, 4).shape
(3, 5, 6, 4)