Diff of /rocaseg/repro/_seed.py [000000] .. [6969be]

Switch to unified view

a b/rocaseg/repro/_seed.py
1
def set_ultimate_seed(base_seed=777):
2
    import os
3
    import random
4
    os.environ['PYTHONHASHSEED'] = str(base_seed)
5
    random.seed(base_seed)
6
7
    try:
8
        import numpy as np
9
        np.random.seed(base_seed)
10
    except ModuleNotFoundError:
11
        print('Module `numpy` has not been found')
12
    try:
13
        import torch
14
        torch.manual_seed(base_seed + 1)
15
        torch.cuda.manual_seed_all(base_seed + 2)
16
        torch.backends.cudnn.deterministic = True
17
    except ModuleNotFoundError:
18
        print('Module `torch` has not been found')