Skip to main content

data2vec_mask

Function data2vec_mask 

Source
pub fn data2vec_mask(
    n_tokens: usize,
    mask_ratio: f32,
    rng: &mut LcgRng,
) -> SslResult<Vec<bool>>
Expand description

Generate a boolean mask of length n_tokens with exactly floor(n_tokens × mask_ratio) positions set to true (= masked).

The selection is performed via a Fisher-Yates partial shuffle over an index array, mirroring the approach in crate::masked::mae::random_patch_mask, but produces a Vec<bool> directly keyed to token indices.

§Errors