mars.tensor.moveaxis#
- mars.tensor.moveaxis(a, source, destination)[源代码]#
Move axes of a tensor to new positions.
Other axes remain in their original order.
- 参数
- 返回
result – Array with moved axes. This tensor is a view of the input tensor.
- 返回类型
Tensor
实际案例
>>> import mars.tensor as mt
>>> x = mt.zeros((3, 4, 5)) >>> mt.moveaxis(x, 0, -1).shape (4, 5, 3) >>> mt.moveaxis(x, -1, 0).shape (5, 3, 4),
These all achieve the same result:
>>> mt.transpose(x).shape (5, 4, 3) >>> mt.swapaxes(x, 0, -1).shape (5, 4, 3) >>> mt.moveaxis(x, [0, 1], [-1, -2]).shape (5, 4, 3) >>> mt.moveaxis(x, [0, 1, 2], [-1, -2, -3]).shape (5, 4, 3)