Initial seed too large?

I trained my model using arbitrary initial seed for randomness. I have printed the seed, (it is a large number, 13248873089935215612). Now as I want to reproduce the training results, I want to set manual seed via
torch.manual_seed(13248873089935215612), but this throws me error in torch/random.py
at line 35 when executing default_generator.manual_seed(seed)

default_generator.manual_seed(seed)
RuntimeError: Overflow when unpacking long

How can I set torch random seed for such large initial seed?

The seed is a signed 64 bit integer on the C++ side, so the maximum is (1<<63)-1.
You could use “13248873089935215612 & ((1<<63)-1)” if you wanted to.

I tend to be cautious about trying to be clever with random seeds, I’m not certain that your seed is any better than, say, 42.

Best regards

Thomas

1 Like