Implementing kernel
C++ engine symbols that back this Python API.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.5Probability of zeroing an entire channel. Must be in
[0, 1].
Default: 0.5.inplacebool= FalseIf
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 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.
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
TrueSee Also
Dropout—Element-wise scalar dropout.Dropout1d—Channel-wise dropout for 3-D inputs.Dropout2d—Channel-wise dropout for 4-D inputs.
Used by 1
Constructors
1Instance methods
2Return a string representation of the layer's configuration.