mindspore.ops.Dropout

class mindspore.ops.Dropout(*args, **kwargs)[source]

During training, randomly zeroes some of the elements of the input tensor with probability.

Parameters
  • keep_prob (float) – 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) – Seed0 value for random generating. Default: 0.

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

Inputs:
  • input (Tensor) - The input of Dropout with data type of float16 or float32.

Outputs:
  • output (Tensor) - with the same shape as the input tensor.

  • mask (Tensor) - with the same shape as the input tensor.

Raises
  • TypeError – If keep_prob is not a float.

  • TypeError – If Seed0 or Seed1 is not an int.

  • TypeError – If dtype of input is neither float16 nor float32.

  • TypeError – If input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

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