MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / set_random_seed

Function set_random_seed

mogen/apis/train.py:17–32  ·  view source on GitHub ↗

Set random seed. Args: seed (int): Seed to be used. deterministic (bool): Whether to set the deterministic option for CUDNN backend, i.e., set `torch.backends.cudnn.deterministic` to True and `torch.backends.cudnn.benchmark` to False. Default:

(seed, deterministic=False)

Source from the content-addressed store, hash-verified

15
16
17def set_random_seed(seed, deterministic=False):
18 """Set random seed.
19 Args:
20 seed (int): Seed to be used.
21 deterministic (bool): Whether to set the deterministic option for
22 CUDNN backend, i.e., set `torch.backends.cudnn.deterministic`
23 to True and `torch.backends.cudnn.benchmark` to False.
24 Default: False.
25 """
26 random.seed(seed)
27 np.random.seed(seed)
28 torch.manual_seed(seed)
29 torch.cuda.manual_seed_all(seed)
30 if deterministic:
31 torch.backends.cudnn.deterministic = True
32 torch.backends.cudnn.benchmark = False
33
34
35def train_model(model,

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected