DropPath#
- class DropPath(drop_prob=0.0)#
Bases:
ModuleDrop paths (stochastic depth) per sample —
nn.Modulewrapper.Thin stateful wrapper around the functional
drop_path()that stores the drop probability and readsself.trainingautomatically, making it a plug-in replacement wherever annn.Moduleis required.Effect on training vs. inference
Training (
model.train()): each sample’s residual branch output is dropped with probabilitydrop_proband kept samples are rescaled by1 / (1 - drop_prob).Inference (
model.eval()): the module is a pure identity; no Bernoulli sampling or scaling is performed.
- drop_prob#
Probability of dropping a sample’s residual output. Typically set between
0.0(no drop) and0.3for deep ViTs.- Type:
- Parameters:
drop_prob (float) – Drop probability. Defaults to
0.0(disabled).
- __init__(drop_prob=0.0)#
Initialise DropPath.
- Parameters:
drop_prob (float) – Probability of dropping each sample’s residual update.
0.0disables the module (pure identity). Default0.0.
- flop_count()#
Return FLOP count — always zero.
DropPath is a stochastic identity (training) or pure identity (inference). The Bernoulli sampling and scalar division are negligible and not counted as floating-point arithmetic.
- Returns:
Always
0.- Return type: