未验证 提交 cb3783a0 编写于 作者: C Chen Long 提交者: GitHub

fix_dead links and remove dropout (#2643)

上级 04dea056
.. _cn_api_nn_Dropout:
Dropout
-------------------------------
.. py:function:: paddle.nn.Dropout(p=0.5, axis=None, mode="upscale_in_train”, name=None)
Dropout是一种正则化手段,该算子根据给定的丢弃概率 `p` ,在训练过程中随机将一些神经元输出设置为0,通过阻止神经元节点间的相关性来减少过拟合。论文请参考: `Improving neural networks by preventing co-adaptation of feature detectors <https://arxiv.org/abs/1207.0580>`_
在动态图模式下,请使用模型的 `eval()` 方法切换至测试阶段。
.. note::
对应的 `functional方法` 请参考: :ref:`cn_api_nn_functional_dropout` 。
参数
:::::::::
- **p** (float): 将输入节点置为0的概率, 即丢弃概率。默认: 0.5。
- **axis** (int|list): 指定对输入 `Tensor` 进行Dropout操作的轴。默认: None。
- **mode** (str): 丢弃单元的方式,有两种'upscale_in_train'和'downscale_in_infer',默认: 'upscale_in_train'。计算方法如下:
1. upscale_in_train, 在训练时增大输出结果。
- train: out = input * mask / ( 1.0 - p )
- inference: out = input
2. downscale_in_infer, 在预测时减小输出结果
- train: out = input * mask
- inference: out = input * (1.0 - p)
- **name** (str,可选): 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
形状
:::::::::
- **输入** : N-D `Tensor` 。
- **输出** : N-D `Tensor` ,形状与输入相同。
代码示例
:::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = np.array([[1,2,3], [4,5,6]]).astype('float32')
x = paddle.to_tensor(x)
m = paddle.nn.Dropout(p=0.5)
y_train = m(x)
m.eval() # switch the model to test phase
y_test = m(x)
print(x.numpy())
print(y_train.numpy())
print(y_test.numpy())
.. _cn_api_nn_cn_dropout:
dropout
-------------------------------
:doc_source: paddle.fluid.layers.dropout
.. _cn_api_fluid_dygraph_Dropout:
.. _cn_api_nn_Dropout:
Dropout
-------------------------------
.. py:class:: paddle.fluid.dygraph.Dropout(p=0.5, seed=None, dropout_implementation='downgrade_in_infer', is_test=False)
.. py:function:: paddle.nn.Dropout(p=0.5, axis=None, mode="upscale_in_train”, name=None)
丢弃或者保持输入的每个元素独立。Dropout是一种正则化手段,通过在训练过程中阻止神经元节点间的相关性来减少过拟合。根据给定的丢弃概率,dropout操作符按丢弃概率随机将一些神经元输出设置为0,其他的仍保持不变。
Dropout是一种正则化手段,该算子根据给定的丢弃概率 `p` ,在训练过程中随机将一些神经元输出设置为0,通过阻止神经元节点间的相关性来减少过拟合。论文请参考: `Improving neural networks by preventing co-adaptation of feature detectors <https://arxiv.org/abs/1207.0580>`_
Dropout层可以删除,提高执行效率
在动态图模式下,请使用模型的 `eval()` 方法切换至测试阶段
参数:
- **p** (float32,可选) - 输入单元的丢弃概率,即输入单元设置为0的概率。默认值:0.5
- **seed** (int,可选) - 整型数据,用于创建随机种子。如果该参数设为None,则使用随机种子。注:如果给定一个整型种子,始终丢弃相同的输出单元。训练过程中勿用固定不变的种子。默认值:None。
- **dropout_implementation** (str,可选) - 丢弃单元的方式,有两种'downgrade_in_infer'和'upscale_in_train'两种选择,默认:'downgrade_in_infer'。具体作用可以参考一下描述。
.. note::
对应的 `functional方法` 请参考: :ref:`cn_api_nn_functional_dropout` 。
1. downgrade_in_infer(default), 在预测时减小输出结果
参数
:::::::::
- **p** (float): 将输入节点置为0的概率, 即丢弃概率。默认: 0.5。
- **axis** (int|list): 指定对输入 `Tensor` 进行Dropout操作的轴。默认: None。
- **mode** (str): 丢弃单元的方式,有两种'upscale_in_train'和'downscale_in_infer',默认: 'upscale_in_train'。计算方法如下:
- train: out = input * mask
1. upscale_in_train, 在训练时增大输出结果。
- inference: out = input * (1.0 - p)
- train: out = input * mask / ( 1.0 - p )
- inference: out = input
(mask是一个张量,维度和输入维度相同,值为0或1,值为0的比例即为 ``p`` )
2. downscale_in_infer, 在预测时减小输出结果
2. upscale_in_train, 增加训练时的结果
- train: out = input * mask
- inference: out = input * (1.0 - p)
- train: out = input * mask / ( 1.0 - p )
- **name** (str,可选): 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
- inference: out = input
形状
:::::::::
- **输入** : N-D `Tensor` 。
- **输出** : N-D `Tensor` ,形状与输入相同。
(mask是一个张量,维度和输入维度相同,值为0或1,值为0的比例即为 ``p`` )
- **is_test** (bool,可选) - 标记是否是测试阶段。此标志仅对静态图模式有效。对于动态图模式,请使用 ``eval()`` 接口。默认:False。
返回:无
**代码示例**:
代码示例
:::::::::
.. code-block:: python
import paddle.fluid as fluid
from paddle.fluid.dygraph.base import to_variable
import paddle
import numpy as np
x = np.random.random(size=(3, 10, 3, 7)).astype('float32')
with fluid.dygraph.guard():
x = to_variable(x)
m = fluid.dygraph.Dropout(p=0.5)
droped_train = m(x)
# 切换到 eval 模式
m.eval()
droped_eval = m(x)
paddle.disable_static()
x = np.array([[1,2,3], [4,5,6]]).astype('float32')
x = paddle.to_tensor(x)
m = paddle.nn.Dropout(p=0.5)
y_train = m(x)
m.eval() # switch the model to test phase
y_test = m(x)
print(x.numpy())
print(y_train.numpy())
print(y_test.numpy())
......@@ -129,7 +129,7 @@
- 新增常见Loss接口`paddle.nn.loss.*`和Metric接口`paddle.metric.*`的封装
- 发布基于高层API实现的12个模型
- Transformer,Seq2seq,LAC,BMN,ResNet,YOLOv3,VGG,MobileNet,TSM,CycleGAN,Bert,OCR
- 发布于[PaddlePaddle/hapi](https://github.com/paddlePaddle/hapi)仓库[examples](https://github.com/PaddlePaddle/hapi/tree/master/examples)目录
- 发布于[PaddlePaddle/hapi](https://github.com/paddlePaddle/hapi)仓库
- **模型执行**
- 新增Model类`paddle.Model`封装,封装模型开发过程中常用的基础功能,包括:
- 提供`Model.summary`接口,用于查看动态图组网的网络结构与参数数量。
......
......@@ -129,7 +129,7 @@ For Version Paddle 2.x, users are recommended to use APIs in the paddle root dir
- **Model Networking**
- Added the encapsulation of the common loss API `paddle.nn.loss.*` and metric API `paddle.metric.*`
- Released 12 models based on high-level API implementations, including Transformer, Seq2seq, LAC, BMN, ResNet, YOLOv3, VGG, MobileNet, TSM, CycleGAN, Bert, OCR. The code can be found in [PaddlePaddle/hapi examples](https://github.com/PaddlePaddle/hapi/tree/master/examples).
- Released 12 models based on high-level API implementations, including Transformer, Seq2seq, LAC, BMN, ResNet, YOLOv3, VGG, MobileNet, TSM, CycleGAN, Bert, OCR. The code can be found in [PaddlePaddle/hapi](https://github.com/PaddlePaddle/hapi).
- **Model Execution**
- Added class API `paddle.Model`, which encapsulates the common model development methods:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册