Skip to content
fn

dropout1d

→Tensor
dropout1d(input: Tensor, p: float = 0.5, training: bool = True, inplace: bool = False)

Implementing kernel

C++ engine symbols that back this Python API.

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/(1−p)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

inputTensor
Input tensor of shape (N,C,L)(N, C, L), or (C,L)(C, L) for one sample with no batch axis. Any other rank raises.
pfloat= 0.5
Channel-drop probability in [0,1][0, 1] (default 0.5).
trainingbool= True
When False, returns input unchanged — identity at inference time (default True).
inplacebool= False
If True, drop channels of input itself and return input (default False).

Returns

Tensor

Same shape and dtype as input.

Notes

For each batch element nn and channel cc, draw mn,c∼Bernoulli(1−p)m_{n,c} \sim \mathrm{Bernoulli}(1 - p) independently and apply

yn,c,ℓ=mn,c1−p⋅xn,c,ℓ.y_{n, c, \ell} = \frac{m_{n, c}}{1 - p} \cdot x_{n, c, \ell}.

The 1/(1−p)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)

Used by 2