Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docathon][Add CN Doc No.33、34] #6431

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/api/paddle/incubate/nn/FusedDropoutAdd_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.. _cn_api_paddle_incubate_nn_FusedDropoutAdd:

FusedDropoutAdd
-------------------------------

.. py:class::paddle.incubate.nn. FusedDropoutAdd ( p=0.5, mode='upscale_in_train', name=None )
Kaedeharai marked this conversation as resolved.
Show resolved Hide resolved

实现了 Dropout 和 Add 的融合

参数
:::::::::
- **p** (float|int, 可选): 将单位设置为零的概率。默认值: 0.5
- **mode** (str, 可选): ['upscale_in_train'(默认) | 'downscale_in_infer']

1. upscale_in_train (默认), 在训练时放大输出

- train: :math:`out = x \times \frac{mask}{(1.0 - p)} + y`
- inference: :math:`out = x + y`

2. downscale_in_infer, 在推理时缩小输出

- train: :math:`out = x \times mask + y`
- inference: :math:`out = x \times (1.0 - p) + y`
- **name** (str, 可选): 操作的名称, 默认值为 None. 有关更多信息请参阅 :ref:`api_guide_Name`.


形状
:::::::::
- x: N-D 张量.
- y: N-D 张量.
- output: N-D 张量, 和 `x` 形状相同.


代码示例
::::::::::

COPY-FROM: paddle.incubate.nn.FusedDropoutAdd
40 changes: 40 additions & 0 deletions docs/api/paddle/incubate/nn/functional/fused_dropout_add_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. _cn_api_paddle_incubate_nn_functional_fused_dropout_add:

fused_dropout_add
-------------------------------

.. py:function:: paddle.incubate.nn.functional.fused_dropout_add(x, y, p=0.5, training=True, mode='upscale_in_train', name=None)

实现了 Dropout 和 Add 的融合

参数
:::::::::
- **x** (Tensor): 输入张量。数据类型为 bfloat16, float16, float32 或 float64.
- **y** (Tensor): 输入张量,数据类型为 bfloat16, float16, float32 或 float64.

Kaedeharai marked this conversation as resolved.
Show resolved Hide resolved
- **p** (float|int, 可选): 将单位设置为零的概率。默认值: 0.5。
- **training** (bool, 可选): 标记是否为训练阶段。默认值: True。
- **mode**(str, 可选): ['upscale_in_train'(默认) | 'downscale_in_infer'].
Kaedeharai marked this conversation as resolved.
Show resolved Hide resolved

1. upscale_in_train (默认), 在训练时放大输出

- 训练: :math:`out = x \times \frac{mask}{(1.0 - dropout\_prob)} + y`
- 推理: :math:`out = x + y`

2. downscale_in_infer, 在推理时缩小输出

- 训练: :math:`out = input \times mask + y`
- 推理: :math:`out = input \times (1.0 - dropout\_prob) + y`

- **name** (str, 可选): 操作的名称, 默认值: None。有关更多信息, 请参阅 :ref:`api_guide_Name`.


返回
:::::::::
- 融合 dropout 和 add 的张量具有与 `x` 相同的形状和数据类型。


代码示例
::::::::::

COPY-FROM: paddle.incubate.nn.functional.fused_dropout_add