mindspore.ops.Dropout3D

View Source On Gitee
class mindspore.ops.Dropout3D(keep_prob=0.5)[source]

During training, randomly zeroes some channels of the input tensor with probability \(1-keep\_prob\) from a Bernoulli distribution(For a 5-dimensional tensor with a shape of NCDHW, the channel feature map refers to a 3-dimensional feature map with a shape of DHW).

Note

The keep probability \(keep\_prob\) is equal to \(1 - p\) in mindspore.ops.dropout3d().

Dropout3D can improve the independence between channel feature maps.

Parameters

keep_prob (float) – The keep probability of a channel, between 0 and 1, e.g. keep_prob = 0.8, means dropping out 20% of channels. Default: 0.5 .

Inputs:
  • x (Tensor) - A 5-D tensor with shape \((N, C, D, H, W)\), where N is the batch size, C is the number of channels, D is the feature depth, H is the feature height, and W is the feature width.

Outputs:
  • output (Tensor) - With the same shape and data type as x.

  • mask (Tensor) - With the same shape as x and the data type is bool.

Raises
  • TypeError – If the data type of keep_prob is not float.

  • ValueError – If keep_prob is out of the range [0.0, 1.0]; or if the dim of input is not 5-D.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> dropout = ops.Dropout3D(keep_prob=0.5)
>>> x = Tensor(np.ones([2, 1, 2, 1, 2]), mindspore.float32)
>>> output, mask = dropout(x)
>>> print(output.shape)
(2, 1, 2, 1, 2)