Spaces:
Running
Running
Create seed.py
Browse files- util/seed.py +15 -0
util/seed.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import random
|
| 3 |
+
import numpy as np
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
def set_seed(seed=1064):
|
| 7 |
+
random.seed(seed)
|
| 8 |
+
np.random.seed(seed)
|
| 9 |
+
torch.manual_seed(seed)
|
| 10 |
+
if torch.cuda.is_available():
|
| 11 |
+
torch.cuda.manual_seed(seed)
|
| 12 |
+
torch.cuda.manual_seed_all(seed)
|
| 13 |
+
torch.backends.cudnn.deterministic = True
|
| 14 |
+
torch.backends.cudnn.benchmark = False
|
| 15 |
+
|