Should I use `random.seed` or `numpy.random.seed` to control random number generation in `scikit-learn`?

Should I use np.random.seed or random.seed? That depends on whether in your code you are using numpy’s random number generator or the one in random. The random number generators in numpy.random and random have totally separate internal states, so numpy.random.seed() will not affect the random sequences produced by random.random(), and likewise random.seed() will not affect … Read more

Generating uniform random numbers in Lua

You need to run math.randomseed() once before using math.random(), like this: math.randomseed(os.time()) From your comment that you saw the first number is still the same. This is caused by the implementation of random generator in some platforms. The solution is to pop some random numbers before using them for real: math.randomseed(os.time()) math.random(); math.random(); math.random() Note … Read more

Reproducible results in Tensorflow with tf.set_random_seed

In tensorflow, a random operation relies on two different seeds: a global seed, set by tf.set_random_seed, and an operation seed, provided as an argument to the operation. You will find more details on how they relate in the docs. You have a different seed for each random op because each random op maintains its own … Read more

Is there an alternative to using time to seed a random number generation?

The rdtsc instruction is a pretty reliable (and random) seed. In Windows it’s accessible via the __rdtsc() intrinsic. In GNU C, it’s accessible via: unsigned long long rdtsc(){ unsigned int lo,hi; __asm__ __volatile__ (“rdtsc” : “=a” (lo), “=d” (hi)); return ((unsigned long long)hi << 32) | lo; } The instruction measures the total pseudo-cycles since … Read more

Is set.seed consistent over different versions of R (and Ubuntu)?

Cross-OS consistency: yes If you installed R on two different operating systems without manually changing defaults or the RProfile, you should get the same results when using set.seed(). Consistency over versions of R: not necessarily It used to be the case that set.seed() would give the same results across R versions, but that’s no longer … Read more

Which seeds have to be set where to realize 100% reproducibility of training results in tensorflow?

The best solution which works as of today with GPU is to install tensorflow-determinism with the following: pip install tensorflow-determinism Then include the following code to your code import tensorflow as tf import os os.environ[‘TF_DETERMINISTIC_OPS’] = ‘1’ source: https://github.com/NVIDIA/tensorflow-determinism

random.seed(): What does it do?

Pseudo-random number generators work by performing some operation on a value. Generally this value is the previous number generated by the generator. However, the first time you use the generator, there is no previous value. Seeding a pseudo-random number generator gives it its first “previous” value. Each seed value will correspond to a sequence of … Read more

Seeding the random number generator in Javascript

No, it is not possible to seed Math.random(). I’ve implemented a number of good, short and fast Pseudorandom number generator (PRNG) functions in plain JavaScript. All of them can be seeded and provide high quality numbers. First of all, take care to initialize your PRNGs properly. To keep things simple, the generators below have no … Read more