Dropout
Zero elements with probability p during training, scaling the rest.
class Dropout : Module— python/vkml/nn.py:544
Advances an offset on every call. The underlying rand is a pure function of (seed, offset, index), so a module reusing one offset would drop the same elements at every step — silently, while the loss curve still looked plausible. The counter is what makes successive masks independent, and there is a test that two consecutive calls differ.
Seeding from a module-local counter rather than a global stream keeps the whole thing reproducible: the same seed replays the same run.
ⓘ Note
p must be in [0, 1). p=0.0 short-circuits to the identity, as does evaluation mode.
Construction¶
__init__¶
Forward¶
forward¶
def forwardself, x: V.Tensor -> V.Tensor— python/vkml/nn.py:565