Python wrappers
Public Python APIs implemented by this engine symbols.Autograd node for standard element-wise (inverted) dropout.
During training, each scalar element of the input is independently
masked with probability p and surviving elements are rescaled by
. The already-scaled mask is saved in mask_
so the backward needs only one multiply — no extra scaling step.
When p == 0 or training == false the node is wired with an
empty mask and apply clones grad_out unchanged.
Attributes
schema_v1OpSchemaRegistered schema (name
"dropout", version 1, AmpPolicy::KeepInput). Marked non-deterministic because the mask depends on the Generator state.p_doubleDrop probability used by the forward; stored for the backward.
0 indicates pass-through.mask_StorageThe scaled Bernoulli mask saved for backward. Empty when
p_ == 0.Static methods
1static
forward
→TensorImplPtrint forward(const int & a, double p, bool training, Generator * gen)Sample the Bernoulli mask and apply inverted-dropout scaling.
Math
\dfrac{x_i}{1 - p} & \text{with probability } 1 - p\\[4pt] 0 & \text{with probability } p \end{cases}$$Parameters
aTensorImplPtrInput tensor of any shape.
pdoubleDrop probability in . Must be strictly less than 1 (probability 1 would zero everything and produce NaN under the scaling).
trainingboolIf
false, the forward is a pass-through.genGenerator*Optional explicit RNG.
nullptr selects the process-wide default_generator(); under deterministic mode the call raises if gen == nullptr and p > 0.Returns
TensorImplPtrOutput tensor of the same shape and dtype as a.
Raises
LucidErrorIf
p is outside , or under deterministic mode if no Generator is provided.