Skip to content

Commit 930e036

Browse files
authored
[Add] feature alpha dropout (#6679)
1 parent 203420b commit 930e036

File tree

6 files changed

+101
-0
lines changed

6 files changed

+101
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.. _cn_api_paddle_nn_FeatureAlphaDropout:
2+
3+
FeatureAlphaDropout
4+
-------------------------------
5+
6+
.. py:function:: paddle.nn.FeatureAlphaDropout(p=0.5, name=None)
7+
8+
一个通道是一个特征图, `FeatureAlphaDropout` 会随机屏蔽掉整个通道。 `AlphaDropout` 是一种具有自归一化性质的 `dropout` 。均值为 0 ,方差为 1 的输入,经过 `AlphaDropout` 计算之后,输出的均值和方差与输入保持一致。 `AlphaDropout` 通常与 SELU 激活函数组合使用。论文请参考:`Self-Normalizing Neural Networks <https://arxiv.org/abs/1706.02515>`_
9+
10+
在动态图模式下,请使用模型的 `eval()` 方法切换至测试阶段。
11+
12+
.. note::
13+
对应的 `functional 方法` 请参考::ref:`cn_api_paddle_nn_functional_feature_alpha_dropout` 。
14+
15+
参数
16+
:::::::::
17+
- **p** (float):将输入节点置 0 的概率,即丢弃概率。默认:0.5。
18+
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
19+
20+
返回
21+
:::::::::
22+
`Tensor` ,经过 FeatureAlphaDropout 之后的结果,与输入 x 形状相同的 `Tensor` 。
23+
24+
代码示例
25+
:::::::::
26+
27+
COPY-FROM: paddle.nn.FeatureAlphaDropout

docs/api/paddle/nn/Overview_cn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ Dropout 层
231231

232232

233233
" :ref:`paddle.nn.AlphaDropout <cn_api_paddle_nn_AlphaDropout>` ", "具有自归一化性质的 dropout"
234+
" :ref:`paddle.nn.FeatureAlphaDropout <cn_api_paddle_nn_FeatureAlphaDropout>` ", "具有自归一化性质的 dropout ,屏蔽整个通道"
234235
" :ref:`paddle.nn.Dropout <cn_api_paddle_nn_Dropout>` ", "Dropout"
235236
" :ref:`paddle.nn.Dropout2D <cn_api_paddle_nn_Dropout2D>` ", "一维 Dropout"
236237
" :ref:`paddle.nn.Dropout3D <cn_api_paddle_nn_Dropout3D>` ", "二维 Dropout"
@@ -462,6 +463,7 @@ Dropout 方法
462463

463464

464465
" :ref:`paddle.nn.functional.alpha_dropout <cn_api_paddle_nn_functional_alpha_dropout>` ", "一种具有自归一化性质的 dropout"
466+
" :ref:`paddle.nn.functional.feature_alpha_dropout <cn_api_paddle_nn_functional_feature_alpha_dropout>` ", "一种具有自归一化性质的 dropout ,屏蔽整个通道"
465467
" :ref:`paddle.nn.functional.dropout <cn_api_paddle_nn_functional_dropout>` ", "Dropout"
466468
" :ref:`paddle.nn.functional.dropout2d <cn_api_paddle_nn_functional_dropout2d>` ", "一维 Dropout"
467469
" :ref:`paddle.nn.functional.dropout3d <cn_api_paddle_nn_functional_dropout3d>` ", "二维 Dropout"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. _cn_api_paddle_nn_functional_feature_alpha_dropout:
2+
3+
feature_alpha_dropout
4+
-------------------------------
5+
6+
.. py:function:: paddle.nn.functional.feature_alpha_dropout(x, p=0.5, training=True, name=None)
7+
8+
一个通道是一个特征图, `feature alpha dropout` 会随机屏蔽掉整个通道。 `alpha dropout` 是一种具有自归一化性质的 `dropout` 。均值为 0 ,方差为 1 的输入,经过 `alpha dropout` 计算之后,输出的均值和方差与输入保持一致。 `alpha dropout` 通常与 SELU 激活函数组合使用。
9+
10+
参数
11+
:::::::::
12+
- **x** (Tensor):输入的多维 `Tensor`,数据类型为:bfloat16、float16、float32 或 float64。
13+
- **p** (float):将输入节点置 0 的概率,即丢弃概率。默认:0.5。
14+
- **training** (bool):标记是否为训练阶段。默认:True。
15+
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
16+
17+
返回
18+
:::::::::
19+
`Tensor` ,经过 feature_alpha_dropout 之后的结果,与输入 x 形状相同的 `Tensor` 。
20+
21+
代码示例
22+
:::::::::
23+
24+
COPY-FROM: paddle.nn.functional.feature_alpha_dropout
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## [ torch 参数更多 ]torch.nn.functional.feature_alpha_dropout
2+
3+
### [torch.nn.functional.feature\_alpha\_dropout](https://pytorch.org/docs/stable/generated/torch.nn.functional.feature_alpha_dropout.html)
4+
5+
```python
6+
torch.nn.functional.feature_alpha_dropout(input, p=0.5, training=False, inplace=False)
7+
```
8+
9+
### [paddle.nn.functional.feature\_alpha\_dropout](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/feature_alpha_dropout_cn.html#feature_alpha-dropout)
10+
11+
```python
12+
paddle.nn.functional.feature_alpha_dropout(x, p=0.5, training=True, name=None)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| -------- | ------------ | -- |
21+
| input | x | 输入的多维 Tensor,仅参数名不一致。 |
22+
| p | p | 将输入节点置 0 的概率。 |
23+
| training | training | 标记是否为训练阶段,PyTorch 默认值为 False,paddle 默认值为 True。 |
24+
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## [torch 参数更多]torch.nn.FeatureAlphaDropout
2+
3+
### [torch.nn.FeatureAlphaDropout](https://pytorch.org/docs/stable/generated/torch.nn.FeatureAlphaDropout.html#torch.nn.FeatureAlphaDropout)
4+
5+
```python
6+
torch.nn.FeatureAlphaDropout(p=0.5, inplace=False)
7+
```
8+
9+
### [paddle.nn.FeatureAlphaDropout](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/FeatureAlphaDropout_cn.html)
10+
11+
```python
12+
paddle.nn.FeatureAlphaDropout(p=0.5, name=None)
13+
```
14+
15+
PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------- | ------------ | --------------------------------------------------------------------------------------------------------------- |
21+
| p | p | 将输入节点置 0 的概率,即丢弃概率。 |
22+
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |

docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
| REFERENCE-MAPPING-ITEM(`torch.all`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.all.md) |
6565
| REFERENCE-MAPPING-ITEM(`torch.allclose`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.allclose.md) |
6666
| REFERENCE-MAPPING-ITEM(`torch.alpha_dropout`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.alpha_dropout.md) |
67+
| REFERENCE-MAPPING-ITEM(`torch.feature_alpha_dropout`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.feature_alpha_dropout.md) |
6768
| REFERENCE-MAPPING-ITEM(`torch.amax`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.amax.md) |
6869
| REFERENCE-MAPPING-ITEM(`torch.amin`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.amin.md) |
6970
| REFERENCE-MAPPING-ITEM(`torch.aminmax`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.aminmax.md) |
@@ -435,6 +436,7 @@
435436
| REFERENCE-MAPPING-ITEM(`torch.nn.AdaptiveMaxPool2d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.AdaptiveMaxPool2d.md) |
436437
| REFERENCE-MAPPING-ITEM(`torch.nn.AdaptiveMaxPool3d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.AdaptiveMaxPool3d.md) |
437438
| REFERENCE-MAPPING-ITEM(`torch.nn.AlphaDropout`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.AlphaDropout.md) |
439+
| REFERENCE-MAPPING-ITEM(`torch.nn.FeatureAlphaDropout`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.FeatureAlphaDropout.md) |
438440
| REFERENCE-MAPPING-ITEM(`torch.nn.AvgPool1d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.AvgPool1d.md) |
439441
| REFERENCE-MAPPING-ITEM(`torch.nn.AvgPool2d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.AvgPool2d.md) |
440442
| REFERENCE-MAPPING-ITEM(`torch.nn.AvgPool3d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.AvgPool3d.md) |

0 commit comments

Comments
 (0)