mindspore.ops.channel_shuffle

查看源文件
mindspore.ops.channel_shuffle(x, groups)[源代码]

将shape为 (,C,H,W) 的tensor的通道划分成 g 组,并按如下方式重新排列 (,Cg,g,HW) ,同时在最终输出中保持原始tensor的shape。

参数:
  • x (Tensor) - 输入tensor。

  • groups (int) - 通道划分数目。

返回:

Tensor

支持平台:

Ascend CPU

样例:

>>> import mindspore
>>> x = mindspore.tensor(mindspore.ops.arange(0, 16, dtype=mindspore.int16).reshape(1, 4, 2, 2))
>>> y = mindspore.ops.channel_shuffle(x, groups=2)
>>> print(y)
[[[[ 0  1]
   [ 2  3]]
   [[ 8  9]
   [10 11]]
   [[ 4  5]
   [ 6  7]]
   [[12 13]
   [14 15]]]]