-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
35 lines (27 loc) · 711 Bytes
/
utils.py
File metadata and controls
35 lines (27 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
""" 유틸리티 함수 모음 """
# python
import os
import shutil
import random
# 3rd-party
import torch
import numpy as np
def seed_everything(seed):
'''
Seeds all the libraries for reproducability
:param int seed: Seed
:return:
'''
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
def make_opts():
if not os.path.exists('opts.py'):
shutil.copy('opts_template.py', 'opts.py')
make_opts()