Skip to content

Commit a246547

Browse files
authored
Additional seeding for reproducibility (#173)
1 parent 39e8d95 commit a246547

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

selene_sdk/utils/config_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import sys
99
from time import strftime
1010
import types
11+
import random
1112

13+
import numpy as np
1214
import torch
1315

1416
from . import _is_lua_trained_model
@@ -335,8 +337,12 @@ def parse_configs_and_run(configs,
335337

336338
if "random_seed" in configs:
337339
seed = configs["random_seed"]
340+
random.seed(seed)
341+
np.random.seed(seed)
338342
torch.manual_seed(seed)
339343
torch.cuda.manual_seed_all(seed)
344+
torch.backends.cudnn.deterministic = True
345+
torch.backends.cudnn.benchmark = False
340346
else:
341347
print("Warning: no random seed specified in config file. "
342348
"Using a random seed ensures results are reproducible.")

0 commit comments

Comments
 (0)