random-seed

Does torch.manual_seed include the operation of torch.cuda.manual_seed_all?

Does torch.manual_seed include the operation of torch.cuda.manual_seed_all? Question: Does torch.manual_seed include the operation of torch.cuda.manual_seed_all? If yes, we can just use torch.manual_seed to set the seed. Otherwise we should call both functions. Asked By: Fengfan Zhou || Source Answers: See Pytorch lightning’s seed_everything: random.seed(seed) np.random.seed(seed) torch.manual_seed(seed) torch.cuda.manual_seed_all(seed) Makes me believe these are all and only …

Total answers: 3

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

Which seeds have to be set where to realize 100% reproducibility of training results in tensorflow? Question: In a general tensorflow setup like model = construct_model() with tf.Session() as sess: train_model(sess) Where construct_model() contains the model definition including random initialization of weights (tf.truncated_normal) and train_model(sess) executes the training of the model – Which seeds do …

Total answers: 4

How can I retrieve the current seed of NumPy's random number generator?

How can I retrieve the current seed of NumPy's random number generator? Question: The following imports NumPy and sets the seed. import numpy as np np.random.seed(42) However, I’m not interested in setting the seed but more in reading it. random.get_state() does not seem to contain the seed. The documentation doesn’t show an obvious answer. How …

Total answers: 6

Generate random integer without an upper bound

Generate random integer without an upper bound Question: I want to generate a random seed in a predictable way. I was hoping to do this seed = 12345 prng_0 = random.Random(seed) prng_1 = random.Random(prng_0.rand_int(0)) There, 0 is the lower bound, but it turns out I need to give it an upper bound as well. I …

Total answers: 3

Python: where is random.random() seeded?

Python: where is random.random() seeded? Question: Say I have some python code: import random r=random.random() Where is the value of r seeded from in general? And what if my OS has no random, then where is it seeded? Why isn’t this recommended for cryptography? Is there some way to know what the random number is? …

Total answers: 1

random.seed(): What does it do?

random.seed(): What does it do? Question: I am a bit confused on what random.seed() does in Python. For example, why does the below trials do what they do (consistently)? >>> import random >>> random.seed(9001) >>> random.randint(1, 10) 1 >>> random.randint(1, 10) 3 >>> random.randint(1, 10) 6 >>> random.randint(1, 10) 6 >>> random.randint(1, 10) 7 I …

Total answers: 12

What is the scope of a random seed in Python?

What is the scope of a random seed in Python? Question: If I use the Python function random.seed(my_seed) in one class in my module, will this seed remain for all the other classes instantiated in this module? Asked By: Lyrositor || Source Answers: Yes, the seed is set for the (hidden) global Random() instance in …

Total answers: 1

Differences between numpy.random and random.random in Python

Differences between numpy.random and random.random in Python Question: I have a big script in Python. I inspired myself in other people’s code so I ended up using the numpy.random module for some things (for example for creating an array of random numbers taken from a binomial distribution) and in other places I use the module …

Total answers: 4