fn

dropout1d

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

Channel-wise dropout for 1-D sequence / feature inputs.

Drops entire 1-D feature maps (channels) of an (N,C,L)(N, C, L) tensor with probability p, scaling the survivors by 1/(1p)1/(1-p) to keep the activation magnitude unbiased. Standard per-element dropout is statistically weak when applied within strongly-correlated feature maps (consecutive positions in a sequence are highly correlated), so masking the whole channel at once provides stronger regularisation in 1-D CNNs and temporal feature extractors.

Parameters

xTensor
Input tensor, typically of shape (N,C,L)(N, C, L).
pfloat= 0.5
Channel-drop probability in [0,1)[0, 1) (default 0.5).
trainingbool= True
When False, returns x unchanged — identity at inference time (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) independently and apply

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

The 1/(1p)1/(1-p) scale ("inverted dropout") preserves E[y]=E[x]\mathbb{E}[y] = \mathbb{E}[x] so no rescaling is needed at inference.

Examples

>>> import lucid
>>> from lucid.nn.functional import dropout1d
>>> x = lucid.ones((2, 4, 5))
>>> y = dropout1d(x, p=0.5, training=True)