17 lines
275 B
Python
17 lines
275 B
Python
|
|
import random
|
||
|
|
|
||
|
|
import numpy as np
|
||
|
|
|
||
|
|
|
||
|
|
def manual_seed(seed=41):
|
||
|
|
random.seed(seed)
|
||
|
|
np.random.seed(seed)
|
||
|
|
try:
|
||
|
|
import torch
|
||
|
|
|
||
|
|
torch.manual_seed(seed)
|
||
|
|
torch.cuda.manual_seed(seed)
|
||
|
|
torch.cuda.manual_seed_all(seed)
|
||
|
|
except:
|
||
|
|
pass
|