Generate a random seed value for reproducible machine learning experiments.
Random seeds control the initialization and stochastic behavior of ML training runs (weight init, data shuffling, dropout masks), so results can vary meaningfully between seeds even with identical hyperparameters. Running the same experiment across multiple seeds and averaging results reduces the standard error of your performance estimate by a factor of √n, which is why reporting mean ± std across 3-5 seeds is considered best practice for credible benchmarking.
seed = floor(random() × (max - min + 1)) + min
3-5 seeds is common for standard benchmarks; for small or noisy datasets, or when claiming a small improvement, use more seeds (5-10) to ensure the effect is not just noise.
Not always — GPU non-determinism (e.g. cuDNN algorithms), multi-threading, and floating-point summation order can still introduce tiny variations even with a fixed seed unless you enable deterministic modes.
Using a single fixed seed risks cherry-picking a lucky (or unlucky) run; testing across multiple seeds reveals the true variance of your method rather than one sample of it.