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

Function set_random_seed

diffplanner/apis/train.py:21–36  ·  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

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

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected