Skip to main content

random_split

Function random_split 

Source
pub fn random_split<D>(
    dataset: Arc<D>,
    lengths: &[SplitLength],
    seed: u64,
) -> Result<Vec<Subset<Arc<D>>>>
where D: Dataset,
Expand description

Randomly partitions a shared dataset into non-overlapping subsets.

Count lengths must sum exactly to the dataset length. Fractional lengths are floored, then leftover samples are assigned round-robin from the first split. The seeded permutation is reproducible within this implementation.

ยงErrors

Returns RustTorchError::InvalidConfiguration for mixed length kinds, invalid fractions, incorrect totals, or count overflow.