Dropout3D

class paddle.nn. Dropout3D ( p=0.5, data_format='NCDHW', name=None ) [source]

Randomly zero out entire channels (in the batched input 5d tensor with the shape NCDHW , a channel is a 3D feature map with the shape DHW ). Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution. Dropout3D will help promote independence between feature maps as described in the paper: Efficient Object Localization Using Convolutional Networks

See dropout3d for more details.

In dygraph mode, please use eval() to switch to evaluation mode, where dropout is disabled.

Parameters
  • p (float | int, optional) – Probability of setting units to zero. Default: 0.5.

  • data_format (str, optional) – Specify the data format of the input, and the data format of the output will be consistent with that of the input. An optional string from NCDHW or NDHWC. When it is NCDHW, the data is stored in the order of: [batch_size, input_channels, input_depth, input_height, input_width]. Default: NCDHW.

  • name (str, optional) – Name for the operation, Default: None. For more information, please refer to Name.

Shape:
  • input: 5-D tensor.

  • output: 5-D tensor, the same shape as input.

Examples

>>> import paddle

>>> x = paddle.arange(24, dtype="float32").reshape((1, 2, 2, 2, 3))
>>> print(x)
Tensor(shape=[1, 2, 2, 2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[[[0. , 1. , 2. ],
    [3. , 4. , 5. ]],
   [[6. , 7. , 8. ],
    [9. , 10., 11.]]],
  [[[12., 13., 14.],
    [15., 16., 17.]],
   [[18., 19., 20.],
    [21., 22., 23.]]]]])

>>> m = paddle.nn.Dropout3D(p=0.5)
>>> y_train = m(x)

>>> m.eval()  # switch the model to test phase
>>> y_test = m(x)
>>> print(y_test)
Tensor(shape=[1, 2, 2, 2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[[[0. , 1. , 2. ],
    [3. , 4. , 5. ]],
   [[6. , 7. , 8. ],
    [9. , 10., 11.]]],
  [[[12., 13., 14.],
    [15., 16., 17.]],
   [[18., 19., 20.],
    [21., 22., 23.]]]]])
forward ( input )

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( )

extra_repr

Extra representation of this layer, you can have custom implementation of your own layer.