Is there any way to find the seed used for initialization?

Hi,
I implemented my code and got good results. Is there any way to find out which seed is used for my results on server code? I didn’t set the seed manually and want to make sure I can reproduce the results.
Thanks

1 Like

Hey,

You can use torch.seed() to get the current seed.
You might want to check the reproducibility part of the doc though: https://pytorch.org/docs/stable/notes/randomness.html as having the seed most likely won’t allow you to reproduce the result if you’re using a different machine or using ops that are not deterministic.

2 Likes

Can you say that what exactly manual.seed() shows? When I set seed at the start of the initialization function, and print torch.seed() for two similar networks, I give bunch of different numbers, but I think since it’s set at the start of the function, any initialization with that seed must be unique. Am I right?

1 Like

You can check the doc here. It returns the value used to initialize the random number generator.
You can also use get/set rng state (https://pytorch.org/docs/stable/torch.html#torch.get_rng_state).

1 Like

I just read the reproducibility, and it seems torch.seed() is to set the seed randomly, not to get the current seed.

4 Likes

torch.random.initial_seed() has provision to provide the seed value. Got it from the torch repo