2.4K Star 8.2K Fork 4.4K

GVPMindSpore / mindspore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dropout_doc.yaml 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
chenfei_mindspore 提交于 2024-02-26 16:24 . move doc.yaml to doc dir
dropout:
description: |
During training, randomly zeroes some of the elements of the input tensor
with probability :math:`1 - keep\_prob` from a Bernoulli distribution. It plays the
role of reducing neuron correlation and avoid overfitting.
Refer to :func:`mindspore.ops.dropout` for more details.
Args:
keep_prob (float, optional): The keep rate, between 0 and 1, e.g. keep_prob = 0.9,
means dropping out 10% of input units. Default: ``0.5`` .
Seed0 (int, optional): Seed0 value for random generating. Default: ``0`` .
Seed1 (int, optional): Seed1 value for random generating. Default: ``0`` .
Inputs:
- **x** (Tensor) - The input Tensor of shape :math:`(*, N)`, with data type of float16, float32 or float64.
Outputs:
- **output** (Tensor) - With the same shape and data type as `x`.
- **mask** (Tensor) - The mask applied to `x`.
- On GPU and CPU, `mask` has the same shape and data type as `x`.
- On Ascend, to achieve a better performance, it is denoted as a 1-D Tensor
with Uint8 data type. It has shape :math:`(byte\_counts, )` where :math:`byte\_counts` is the
number of bytes needed to mask the input `x`, :math:`byte\_counts` is calculated using the
following formula:
.. math::
byte\_counts = \text{ceil}(\text{cumprod}(x.shape) / 128) * 16
If shape of `x` is :math:`(2, 3, 4, 5, 6)`, the shape of `mask` will be :math:`(96, )`.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> 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, mask.shape, mask.dtype)
(1, 2, 3, 4, 5) (16,) UInt8
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore
master

搜索帮助