dropout1d
- paddle.nn.functional. dropout1d ( input: Tensor, p: float = 0.5, training: bool = True, inplace: bool = False ) Tensor [source]
-
Randomly zero out entire 1D channels (feature maps) during training.
- Parameters
-
input – Input tensor of shape [C, L] (2D) or [N, C, L] (3D)
p – Probability of a channel being zeroed. Default: 0.5
training – If False, returns input unchanged. Default: True
inplace – If True, modifies input tensor in-place. Default: False WARNING: Currently not implemented (will behave as False). TODO: Implement in-place operation in future versions. Default: False
- Returns
-
Tensor with the same shape as input, where entire channels are zeroed with probability p
Examples
>>> import paddle # Case 1: 3D input (batched) >>> x = paddle.randn([2, 3, 10]) # [N, C, L] >>> y_train = paddle.nn.functional.dropout1d(x, p=0.2) # Training mode >>> y_test = paddle.nn.functional.dropout1d(x, p=0.2, training=False) # Test mode >>> print("Original first channel:", x[0, 0, :]) >>> print("Train output (may be zeroed):", y_train[0, 0, :]) >>> print("Test output (always unchanged):", y_test[0, 0, :]) # Case 2: 2D input (single sample) >>> x = paddle.randn([3, 8]) # [C, L] >>> y = paddle.nn.functional.dropout1d(x, p=0.5) >>> print("Input shape:", x.shape) >>> print("Output shape:", y.shape) >>> print("Zeroed channels count:", paddle.sum(y == 0).item())