fn

dropout3d

Tensor
dropout3d(x: Tensor, p: float = 0.5, training: bool = True)
source

Channel-wise dropout for 3-D (volumetric) feature maps.

Drops entire 3-D feature maps of an (N,C,D,H,W)(N, C, D, H, W) tensor with probability p and rescales survivors by 1/(1p)1/(1-p). Used in 3-D ConvNets for video and volumetric medical imaging, where spatio-temporal locality makes per- element dropout statistically inefficient (same rationale as dropout2d).

Parameters

xTensor
Input tensor of shape (N,C,D,H,W)(N, C, D, H, W).
pfloat= 0.5
Channel-drop probability in [0,1)[0, 1) (default 0.5).
trainingbool= True
When False, identity (default True).

Returns

Tensor

Same shape and dtype as x.

Notes

For each batch element nn and channel cc, draw mn,cBernoulli(1p)m_{n,c} \sim \mathrm{Bernoulli}(1 - p) and broadcast over the volumetric dimensions:

yn,c,d,h,w=mn,c1pxn,c,d,h,w.y_{n, c, d, h, w} = \frac{m_{n, c}}{1 - p} \cdot x_{n, c, d, h, w}.

Examples

>>> import lucid
>>> from lucid.nn.functional import dropout3d
>>> x = lucid.ones((1, 4, 3, 4, 4))
>>> y = dropout3d(x, p=0.5, training=True)