mindspore.ops.dropout

mindspore.ops.dropout(input, p=0.5, training=True, seed=None)[source]

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. The meaning of probability here is opposite to that in ops.Dropout and nn.Dropout.

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

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

  • training (bool) – Apply dropout if is True. Default: True.

  • seed (int, optional) – Seed is used as entropy source for Random number engines generating pseudo-random numbers. Default: None, which will be treated as 0.

Returns

  • output (Tensor) - Zeroed tensor, with the same shape and data type as input.

Raises
  • TypeError – If p is not a float.

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

  • TypeError – If input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

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