mindspore.ops.ChannelShuffle

class mindspore.ops.ChannelShuffle(group)[source]

Divide the channels in a tensor of shape \((*, C, H, W)\) into \(g\) group and rearrange them as \((*, \frac C g, g, H*W)\), while keeping the original tensor shapes.

Warning

This is an experimental API that is subject to change or deletion.

Refer to mindspore.ops.channel_shuffle() for more detail.

Parameters

group (int) – Number of group to divide channels in.

Inputs:
  • x (Tensor) - Tensor to be divided, it has shape \((*, C, H, W)\), with float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64 data type.

Outputs:

A Tensor, has the same type as the x, and has the shape \((*, C, H, W)\).

Supported Platforms:

Ascend CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> group = 2
>>> x = Tensor(np.arange(1 * 4 * 2 * 2).reshape(1, 4, 2, 2).astype(np.int16))
>>> channel_shuffle_func = ops.ChannelShuffle(group)
>>> y = channel_shuffle_func(x)
>>> print(y)
[[[[ 0  1]
   [ 2  3]]
   [[ 8  9]
   [10 11]]
   [[ 4  5]
   [ 6  7]]
   [[12 13]
   [14 15]]]]