A random-seed is used to initialize a pseudo-random number generator in many programming languages.
Questions tagged [random-seed]
937 questions
9
votes
1 answer
How is the seed chosen if not set by the user?
For the purpose of reproducibility, one has to choose a seed. In R, we can use set.seed().
My question is, when the seed is not set explicitly, how does the computer choose the seed?
Why is there no default seed?

John Smith
- 1,604
- 4
- 18
- 45
9
votes
3 answers
How should OpenAI environments (gyms) use env.seed(0)?
I've created a very simple OpenAI gym (banana-gym) and wonder if / how I should implement env.seed(0).
See https://github.com/openai/gym/issues/250#issuecomment-234126816 for example.

Martin Thoma
- 124,992
- 159
- 614
- 958
9
votes
4 answers
Which seeds have to be set where to realize 100% reproducibility of training results in tensorflow?
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…

Oblomov
- 8,953
- 22
- 60
- 106
9
votes
1 answer
C# - Random number with seed
I have this code:
var rand = new Random(0);
for(int i = 0; i < 100; i++)
{
Console.WriteLine(rand.Next(0, 100));
}
And program should give me 100 times the same number (because seed is the same), but it gives different numbers...
Why?
Edit:
When…

TheChilliPL
- 337
- 1
- 5
- 14
9
votes
2 answers
TensorFlow: How to apply the same image distortion to multiple images
Starting from the Tensorflow CNN example, I'm trying to modify the model to have multiple images as an input (so that the input has not just 3 input channels, but multiples of 3 by stacking images).
To augment the input, I try to use random image…

b3nk4n
- 1,101
- 1
- 11
- 17
9
votes
1 answer
controlling seeds with mclapply
Imagine we are doing a number of processes where i want to set one overall seed at the beginning of a program: e.g.
mylist <- list( as.list(rep(NA,3)), as.list(rep(NA,3)) )
foo <- function(x){ for(i in 1:length(x)){
x[[i]]…

user1320502
- 2,510
- 5
- 28
- 46
9
votes
1 answer
postgres random using setseed
I would like to add a column with a random number using setseed to a table.
The original table structure (test_input) col_a,col_b,col_c
Desired output (test_output) col_a, col_b, col_c, random_id
The following returns the same random_id on all…

user3416355
- 99
- 1
- 1
- 2
8
votes
3 answers
Is it possible to have rails log errors when seeding
I have a rails app with a lot of information in the seed process. Is there a way to set it so that it logs to one of the log files?

timpone
- 19,235
- 36
- 121
- 211
8
votes
2 answers
Parallel processing in R - setting seed with mclapply() vs. pbmclapply()
I'm parallelizing simulations in R (using mclapply() from the parallel package) and wanted to track my progress with each function call. So I instead decided to use pbmclapply() from the pbmcapply package in order to have a progress bar each time I…

bob
- 610
- 5
- 23
8
votes
2 answers
How do I assign a random seed to the dplyr sample_n function?
This is the "sample_n" from dplyr in R.
https://dplyr.tidyverse.org/reference/sample.html
For reproducibility, I should place a seed so that someone else can get my exact results.
Is there a built-in way to set the seed for "sample_n"?
Is this…

EngrStudent
- 1,924
- 31
- 46
8
votes
3 answers
How to get absolutely reproducible results with Scikit Learn?
Regarding the seeding system when running machine learning algorithms with Scikit-Learn, there are three different things usually mentioned:
random.seed
np.random.seed
random_state at SkLearn (cross-validation iterators, ML algorithms etc)
I have…

Outcast
- 4,967
- 5
- 44
- 99
8
votes
2 answers
What's the best way to create a "good" SecureRandom?
There are a lot of questions asking if a specific initiation of SecureRandom is "good", but I couldn't find a rule of thumb.
What's the best way to create a "good" random SecureRandom?
// Fast
// Is it a good random?
SecureRandom secureRandom = new…

AlikElzin-kilaka
- 34,335
- 35
- 194
- 277
8
votes
3 answers
Determinism in tensorflow gradient updates?
So I have a very simple NN script written in Tensorflow, and I am having a hard time trying to trace down where some "randomness" is coming in from.
I have recorded the
Weights,
Gradients,
Logits
of my network as I train, and for the first…

Spacey
- 2,941
- 10
- 47
- 63
8
votes
1 answer
ThreadLocalRandom setSeed
Is it possible to provide a Seed to a ThreadLocalRandom?
It looks like it isn't.
/**
* Throws {@code UnsupportedOperationException}. Setting seeds in
* this generator is not supported.
*
* @throws UnsupportedOperationException always
…

Charles Follet
- 827
- 1
- 10
- 28
8
votes
3 answers
Set seed on Math.random()
I need to write some junit tests on Java code that calls Math.random(). I know that I can set the seed if I was instantiating my own Random object to produce repeatable results. Is there a way to do this also for Math.random() ?

Kevin
- 11,521
- 22
- 81
- 103