Dropout3d
ModuleDropout3d(p: float = 0.5, inplace: bool = False)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:
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[0, 1].
Default: 0.5.inplacebool= FalseTrue, 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 fullD × H × Wspatial 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
TrueMethods (3)
__init__
→None__init__(p: float = 0.5, inplace: bool = False)Initialise the Dropout3d module. See the class docstring for parameter semantics.
forward
→Tensorforward(x: Tensor)Apply dropout to the input tensor.
Parameters
inputTensorReturns
TensorOutput tensor of the same shape as input; in eval mode this is
the identity.
extra_repr
→strextra_repr()Return a string representation of the layer's configuration.