Skip to content

Commit

Permalink
Update ChannelShuffle_cn.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
BrilliantYuKaimin committed Apr 19, 2022
1 parent 02bfe29 commit b2c69af
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions docs/api/paddle/nn/ChannelShuffle_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,24 @@ ChannelShuffle
-------------------------------

.. py:function:: paddle.nn.ChannelShuffle(groups, data_format="NCHW", name=None)
该算子将一个形为[N, C, H, W]或是[N, H, W, C]的Tensor按通道分成g组,得到形为[N, g, C/g, H, W][N, H, W, g, C/g]的Tensor,然后转置为[N, C/g, g, H, W][N, H, W, C/g, g]的形状,最后重塑为原来的形状。这样做可以增加通道间的信息流动,提高特征的重用率。详见张祥雨等人在2017年发表的论文 `ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices <https://arxiv.org/abs/1707.01083>`_ 。
该算子将一个形为 [N, C, H, W] 或是 [N, H, W, C] 的 Tensor 按通道分成 g 组,得到形为 [N, g, C/g, H, W][N, H, W, g, C/g] 的 Tensor,然后转置为 [N, C/g, g, H, W][N, H, W, C/g, g] 的形状,最后重塑为原来的形状。这样做可以增加通道间的信息流动,提高特征的重用率。详见张祥雨等人在 2017 年发表的论文 `ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices <https://arxiv.org/abs/1707.01083>`_ 。


参数
:::::::::
- **groups** (int): 要把通道分成的组数
- **data_format** (str,可选): 数据格式,可选:"NCHW"或"NHWC",默认: "NCHW";
- **name** (str,可选): 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
- **groups** (int)要把通道分成的组数
- **data_format** (str,可选)数据格式,可选:NCHWNHWC,默认为 NCHW,即(批大小,通道数,高度,宽度)的格式。
- **name** (str,可选)操作的名称可选,默认值为 None),大多数情况下不需要设置此属性。更多信息请参见 :ref:`api_guide_Name`。

形状
:::::::::
- **x** (Tensor): 默认形状为 (批大小,通道数,高度,宽度),即NCHW格式的4-D Tensor。其数据类型为float32, float64
- **output** (Tensor): 其形状与数据类型均和输入相同。
- **x** (Tensor) – 默认形状为(批大小,通道数,高度,宽度),即 NCHW 格式的 4-D Tensor。其数据类型为 float32 或 float64
- **out** (Tensor) 其形状与数据类型均和输入相同。

返回
:::::::::
计算ChannelShuffle的可调用对象
计算 ChannelShuffle 的可调用对象

代码示例
:::::::::
.. code-block:: python
import paddle
import paddle.nn as nn
x = paddle.arange(0, 0.6, 0.1, 'float32')
x = paddle.reshape(x, [1, 6, 1, 1])
# [[[[0. ]],
# [[0.10000000]],
# [[0.20000000]],
# [[0.30000001]],
# [[0.40000001]],
# [[0.50000000]]]]
channel_shuffle = nn.ChannelShuffle(3)
y = channel_shuffle(x)
# [[[[0. ]],
# [[0.20000000]],
# [[0.40000001]],
# [[0.10000000]],
# [[0.30000001]],
# [[0.50000000]]]]
COPY-FROM: paddle.nn.ChannelShuffle:ChannelShuffle-example

0 comments on commit b2c69af

Please sign in to comment.