mindspore.ops.transpose
- mindspore.ops.transpose(input, input_perm)[源代码]
根据指定的维度排列顺序对输入tensor进行维度转置。
说明
GPU和CPU平台上,如果 input_perm 的元素值为负数,则其实际值为 input_perm[i] + rank(input) 。 Ascend平台不支持 input_perm 元素值为负。
- 参数:
input (Tensor) - 输入tensor。
input_perm (tuple[int]) - 指定轴的新排列。
- 返回:
Tensor
- 支持平台:
Ascend
GPU
CPU
样例:
>>> import mindspore >>> input = mindspore.tensor([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]], mindspore.float32) >>> output = mindspore.ops.transpose(input, (0, 2, 1)) >>> print(output) [[[ 1. 4.] [ 2. 5.] [ 3. 6.]] [[ 7. 10.] [ 8. 11.] [ 9. 12.]]]