Skip to content
class

DropoutNdBackward

DropoutNdBackward

Python wrappers

Public Python APIs implemented by this engine symbols.

Autograd node for channel-wise Dropout.

A single Bernoulli value is drawn per (batch, channel) pair on a compact (N,C,1,1,…)(N, C, 1, 1, \ldots) mask, then expanded by the backend to the full input shape so that entire feature-map channels are zeroed together. This is the C++ kernel behind the Python Dropout1d / Dropout2d / Dropout3d modules — input rank must be at least 2 and the layout is assumed to be (N,C,spatial…)(N, C, \text{spatial}\ldots).

Attributes

schema_v1OpSchema
Registered schema (name "dropoutnd", version 1, AmpPolicy::KeepInput).
p_double
Drop probability used by the forward; stored for the backward.
mask_Storage
Full-resolution mask after the broadcast — same shape as the input. Saved so the backward is a single multiply.

Static methods

1
static

forward

→TensorImplPtr
int forward(const int & a, double p, bool training, Generator * gen)

Sample a channel mask and broadcast-multiply with the input.

Math

\dfrac{x_{n,c,\ldots}}{1 - p} & \text{with probability } 1 - p\\[4pt] \mathbf{0} & \text{with probability } p \end{cases}$$

Parameters

aTensorImplPtr
Input tensor of rank ≥2\geq 2 in layout (N,C,spatial…)(N, C, \text{spatial}\ldots).
pdouble
Channel drop probability in [0,1)[0, 1).
trainingbool
If false, the forward is a pass-through.
Optional RNG (see DropoutBackward).

Returns

TensorImplPtr

Output tensor with the same shape and dtype as a.

Raises

LucidError
If a has fewer than 2 dimensions, p is outside [0,1)[0, 1), or deterministic mode is on without a Generator.

Methods

3
fn

apply

int apply(int grad_out)

Backward: multiply grad_out by the saved full-resolution mask.

fn

apply_for_graph

int apply_for_graph(const int & grad_out)
fn

release_own_saved

void release_own_saved()