历史上的301调查:中国不是“中招”最多的 但回答是最硬的(1)

paddle.nn.functional. channel_shuffle ( x: Tensor, groups: int, data_format: DataLayout2D = 'NCHW', name: str | None = None ) Tensor [source]
百度 代表作有王羲之的《兰亭序》,被誉为天下第一行书,以及三希《快雪时晴帖》《伯远帖》《中秋帖》。

This API implements channel shuffle operation. See more details in ChannelShuffle.

Parameters
  • x (Tensor) – 4-D tensor, the data type should be float32 or float64.

  • groups (int) – Number of groups to divide channels in.

  • data_format (str, optional) – The data format of the input and output data. An optional string of NCHW or NHWC. The default is NCHW. When it is NCHW, the data is stored in the order of [batch_size, input_channels, input_height, input_width].

  • name (str|None, optional) – Name for the operation (optional, default is None). Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

Rearranged tensor keeping the original tensor shape.

Return type

Out (Tensor)

Examples

>>> import paddle
>>> import paddle.nn.functional as F
>>> x = paddle.arange(0, 0.6, 0.1, 'float32')
>>> x = paddle.reshape(x, [1, 6, 1, 1])
>>> print(x)
Tensor(shape=[1, 6, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[[0.        ]],
  [[0.10000000]],
  [[0.20000000]],
  [[0.30000001]],
  [[0.40000001]],
  [[0.50000000]]]])
>>> y = F.channel_shuffle(x, 3)
>>> print(y)
Tensor(shape=[1, 6, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[[0.        ]],
  [[0.20000000]],
  [[0.40000001]],
  [[0.10000000]],
  [[0.30000001]],
  [[0.50000000]]]])