mindspore.ops.Dropout
- class mindspore.ops.Dropout(keep_prob=0.5, Seed0=0, Seed1=0)[source]
During training, randomly zeroes some of the elements of the input tensor with probability
from a Bernoulli distribution. It plays the role of reducing neuron correlation and avoid overfitting.Refer to
mindspore.ops.dropout()
for more details.- Parameters
- Inputs:
x (Tensor) - The input Tensor of shape
, 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
where is the number of bytes needed to mask the input x, is calculated using the following formula:If shape of x is
, the shape of mask will be .
- 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