LANGUAGE/PyTorch
How to set Random Seed for PyTorch?
Hogeony
2021. 5. 17. 10:16
SEED = 0
torch.manual_seed(SEED)
torch.cuda.manual_seed_all(SEED)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
np.random.seed(SEED)
random.seed(SEED)
# References
https://discuss.pytorch.org/t/what-does-torch-backends-cudnn-benchmark-do/5936/7
What does torch.backends.cudnn.benchmark do?
Does it work to turn it on for training (where I have a constant input size) and turn it off for validation (where my input size isn’t constant)? Do I just set the constant before doing my validation?
discuss.pytorch.org