class

Dropout3d

extendsModule
Dropout3d(p: float = 0.5, inplace: bool = False)
source

Randomly zero entire volumetric feature-map channels during training.

Extends channel-wise dropout to 5-D inputs of shape (N, C, D, H, W). A single Bernoulli draw per channel per sample determines whether that entire volumetric feature map is zeroed:

yn,c,:,:,:={xn,c,:,:,:1pwith probability 1p0with probability p(training)y_{n,c,:,:,:} = \begin{cases} \dfrac{x_{n,c,:,:,:}}{1 - p} & \text{with probability } 1 - p \\[6pt] \mathbf{0} & \text{with probability } p \end{cases} \quad \text{(training)}

This is the natural generalisation of Dropout2d to 3-D convolutional networks (e.g. video models or volumetric medical imaging). Because adjacent voxels within a feature map are strongly correlated, element-wise dropout would have little regularisation effect; zeroing the entire channel is a stronger signal.

Parameters

pfloat= 0.5
Probability of zeroing an entire channel. Must be in [0, 1]. Default: 0.5.
inplacebool= False
If True, modify the input in place. Default: False.

Notes

  • Input: (N, C, D, H, W) — batch of 3-D feature volumes.
  • Output: (N, C, D, H, W) — same shape; zeroed channels are zero across the full D × H × W spatial extent.

The mask is sampled on the (N, C) axes and broadcast over (D, H, W). In eval mode the layer is the identity.

Dropout : Element-wise scalar dropout. Dropout1d : Channel-wise dropout for 3-D inputs. Dropout2d : Channel-wise dropout for 4-D inputs.

Examples

After a 3-D convolutional layer:
>>> import lucid, lucid.nn as nn
>>> drop3d = nn.Dropout3d(p=0.1)
>>> drop3d.train()
>>> x = lucid.ones(2, 8, 4, 4, 4)    # (N=2, C=8, D=4, H=4, W=4)
>>> y = drop3d(x)
>>> y.shape
(2, 8, 4, 4, 4)
No-op in eval mode:
>>> drop3d.eval()
>>> y_eval = drop3d(lucid.ones(1, 4, 2, 2, 2))
>>> float(y_eval.sum()) == 32.0
True

Methods (3)

dunder

__init__

None
__init__(p: float = 0.5, inplace: bool = False)
source

Initialise the Dropout3d module. See the class docstring for parameter semantics.

fn

forward

Tensor
forward(x: Tensor)
source

Apply dropout to the input tensor.

Parameters

inputTensor
Input tensor of arbitrary shape.

Returns

Tensor

Output tensor of the same shape as input; in eval mode this is the identity.

fn

extra_repr

str
extra_repr()
source

Return a string representation of the layer's configuration.