-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【PaddlePaddle Hackathon 2】24、为 Paddle 新增 nn.ChannelShuffle 组网 API (#4501
) * Create docs for channel shuffle * Update docs for channel shuffle * add ChannelShuffle * Update ChannelShuffle_cn.rst * Update channel_shuffle_cn.rst
- Loading branch information
1 parent
a461db8
commit 9e8b71c
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.. _cn_api_nn_ChannelShuffle: | ||
|
||
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>`_ 。 | ||
|
||
|
||
参数 | ||
::::::::: | ||
- **groups** (int) – 要把通道分成的组数。 | ||
- **data_format** (str,可选) – 数据格式,可选:NCHW 或 NHWC,默认为 NCHW,即(批大小,通道数,高度,宽度)的格式。 | ||
- **name** (str,可选) – 操作的名称(可选,默认值为 None),大多数情况下不需要设置此属性。更多信息请参见 :ref:`api_guide_Name`。 | ||
|
||
形状 | ||
::::::::: | ||
- **x** (Tensor) – 默认形状为(批大小,通道数,高度,宽度),即 NCHW 格式的 4-D Tensor。其数据类型为 float32 或 float64。 | ||
- **out** (Tensor) – 其形状与数据类型均和输入相同。 | ||
|
||
返回 | ||
::::::::: | ||
计算 ChannelShuffle 的可调用对象。 | ||
|
||
代码示例 | ||
::::::::: | ||
COPY-FROM: paddle.nn.ChannelShuffle:ChannelShuffle-example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. _cn_api_nn_functional_channel_shuffle: | ||
|
||
|
||
channel_shuffle | ||
------------------------------- | ||
|
||
.. py:function:: paddle.nn.functional.channel_shuffle(x, 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>`_ 。 | ||
|
||
.. note:: | ||
详细请参考对应的 `Class` 请参考: :ref:`cn_api_nn_ChannelShuffle`。 | ||
|
||
参数 | ||
::::::::: | ||
- **x** (Tensor) – 当前算子的输入,其是一个形状为 [N, C, H, W] 的 4-D Tensor。其中 N 是批大小,C 是通道数,H 是输入特征的高度,W 是输入特征的宽度。其数据类型为 float32 或 float64。 | ||
- **groups** (int) – 要把通道分成的组数; | ||
- **data_format** (str,可选) – 数据格式,可选:NCHW 或 NHWC,默认为 NCHW,即(批大小,通道数,高度,宽度)的格式。 | ||
- **name** (str,可选) – 操作的名称(可选,默认值为 None),大多数情况下不需要设置此属性。更多信息请参见 :ref:`api_guide_Name`。 | ||
|
||
返回 | ||
::::::::: | ||
``Tensor``,调整过通道顺序的 Tensor,其数据类型与输入相同。 | ||
|
||
代码示例 | ||
::::::::: | ||
COPY-FROM: paddle.nn.functional.channel_shuffle:channel_shuffle-example |