Skip to main content

dropout

Function dropout 

Source
pub fn dropout(x: &[f32], p: f32, scale: f32, seed: u32) -> Vec<f32>
Expand description

Inverted dropout with a counter-based RNG: element i is kept when hash(seed, i) maps to u >= p, and scaled by scale (the caller-computed 1/(1-p)). Applying the same (seed, p, scale) to dy gives the backward pass. scale is passed in (rather than recomputed here) so the CPU and WGSL kernel multiply by the exact same bits — see ops::dropout.