forked from mindspore-Ecosystem/mindspore
fix dropout doc
This commit is contained in:
parent
5a96e68502
commit
a8b68b6e9c
|
@ -5,7 +5,7 @@ mindspore.nn.Dropout
|
|||
|
||||
随机丢弃层。
|
||||
|
||||
Dropout是一种正则化手段,该算子根据丢弃概率 :math:`1 - keep\_prob` 。在训练过程中随机将一些神经元输出设置为0,通过阻止神经元节点间的相关性来减少过拟合。在推理过程中,此层返回与 `x` 相同的Tensor。
|
||||
Dropout是一种正则化手段,该算子根据丢弃概率 :math:`1 - keep\_prob`,在训练过程中随机将一些神经元输出设置为0,通过阻止神经元节点间的相关性来减少过拟合。在推理过程中,此层返回与 `x` 相同的Tensor。
|
||||
|
||||
论文 `Dropout: A Simple Way to Prevent Neural Networks from Overfitting <http://www.cs.toronto.edu/~rsalakhu/papers/srivastava14a.pdf>`_ 中提出了该技术,并证明其能有效地减少过度拟合,防止神经元共适应。更多详细信息,请参见 `Improving neural networks by preventing co-adaptation of feature detectors <https://arxiv.org/pdf/1207.0580.pdf>`_ 。
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ mindspore.ops.dropout
|
|||
|
||||
.. py:function:: mindspore.ops.dropout(x, p=0.5, seed0=0, seed1=0)
|
||||
|
||||
在训练期间,以服从伯努利分布的概率 `p` 随机将输入Tensor的某些值归零,起到减少神经元相关性的作用,避免过拟合。
|
||||
在训练期间,以服从伯努利分布的概率 `p` 随机将输入Tensor的某些值归零,起到减少神经元相关性的作用,避免过拟合。此概率与 `ops.dropout` 和 `nn.dropout` 中的含义相反。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - dropout的输入,任意维度的Tensor,其数据类型为float16或float32。
|
||||
|
@ -12,8 +12,8 @@ mindspore.ops.dropout
|
|||
- **seed1** (int,可选) - 全局的随机种子,和算子层的随机种子共同决定最终生成的随机数。默认值:0。
|
||||
|
||||
返回:
|
||||
- **output** (Tensor) - shape和数据类型与 `x` 相同。
|
||||
- **mask** (Tensor) - shape与 `x` 相同。
|
||||
- **output** (Tensor) - 归零后的Tensor,shape和数据类型与 `x` 相同。
|
||||
- **mask** (Tensor) - 用于归零的掩码,内部会按位压缩与对齐。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `p` 不是float。
|
||||
|
|
|
@ -1063,7 +1063,8 @@ def dropout(x, p=0.5, seed0=0, seed1=0):
|
|||
"""
|
||||
During training, randomly zeroes some of the elements of the input tensor
|
||||
with probability `p` from a Bernoulli distribution. It plays the role of
|
||||
reducing neuron correlation and avoid overfitting.
|
||||
reducing neuron correlation and avoid overfitting. The meaning of probability
|
||||
here is opposite to that in `ops.dropout` and `nn.dropout`.
|
||||
|
||||
Args:
|
||||
x (Tensor): The input of Dropout, a Tensor of any shape with data type of float16 or float32.
|
||||
|
@ -1073,8 +1074,8 @@ def dropout(x, p=0.5, seed0=0, seed1=0):
|
|||
seed1 (int, optional): seed1 value for random generating. Default: 0.
|
||||
|
||||
Returns:
|
||||
- **output** (Tensor) - With the same shape and data type as `x`.
|
||||
- **mask** (Tensor) - With the same shape as `x`.
|
||||
- **output** (Tensor) - Zeroed tensor, with the same shape and data type as `x`.
|
||||
- **mask** (Tensor) - Mask for zeroing, bitwise compression and alignment are performed internally.
|
||||
|
||||
Raises:
|
||||
TypeError: If `p` is not a float.
|
||||
|
@ -1088,8 +1089,8 @@ def dropout(x, p=0.5, seed0=0, seed1=0):
|
|||
Examples:
|
||||
>>> x = Tensor(((20, 16), (50, 50)), mindspore.float32)
|
||||
>>> output, mask = ops.dropout(x, p=0.5)
|
||||
>>> print(output.shape)
|
||||
(2, 2)
|
||||
>>> print(output.shape, mask.shape, mask.dtype)
|
||||
(2, 2) (16,) UInt8
|
||||
"""
|
||||
keep_prob = 1 - p
|
||||
dropout_ = P.Dropout(keep_prob=keep_prob, Seed0=seed0, Seed1=seed1)
|
||||
|
|
|
@ -6940,11 +6940,11 @@ class Dropout(PrimitiveWithCheck):
|
|||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> dropout = ops.Dropout3D(keep_prob=0.5)
|
||||
>>> dropout = ops.Dropout(keep_prob=0.5)
|
||||
>>> x = Tensor(np.ones([1, 2, 3, 4, 5]), mindspore.float32)
|
||||
>>> output, mask = dropout(x)
|
||||
>>> print(output.shape)
|
||||
(1, 2, 3, 4, 5)
|
||||
>>> print(output.shape, mask.shape, mask.dtype)
|
||||
(1, 2, 3, 4, 5) (16,) UInt8
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
|
Loading…
Reference in New Issue