maxframe.tensor.swapaxes#
- maxframe.tensor.swapaxes(a, axis1, axis2)[源代码]#
交换张量的两个轴。
- 参数:
- 返回:
a_swapped -- 如果 a 是一个 Tensor,则返回 a 的视图;否则创建一个新张量。
- 返回类型:
Tensor
示例
>>> import maxframe.tensor as mt
>>> x = mt.array([[1,2,3]]) >>> mt.swapaxes(x,0,1).execute() array([[1], [2], [3]])
>>> x = mt.array([[[0,1],[2,3]],[[4,5],[6,7]]]) >>> x.execute() array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]])
>>> mt.swapaxes(x,0,2).execute() array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]])