mindspore.ops.dropout

mindspore.ops.dropout(x, p=0.5, seed0=0, seed1=0)[source]

During training, randomly zeroes some of the elements of the input tensor with probability p from a Bernoulli distribution.

Parameters
  • x (Tensor) – The input of Dropout, a Tensor of any shape with data type of float16 or float32.

  • p (float) – The dropping rate, between 0 and 1, e.g. p = 0.1, means dropping out 10% of input units. Default: 0.5.

  • seed0 (int) – seed0 value for random generating. Default: 0.

  • seed1 (int) – 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.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> from mindspore.ops import dropout
>>> x = Tensor(((20, 16), (50, 50)), mindspore.float32)
>>> output, mask = dropout(x, p=0.5)
>>> print(output.shape)
(2, 2)