-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpyOMT_utils.py
27 lines (24 loc) · 875 Bytes
/
pyOMT_utils.py
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
import os, shutil
import pdb
def progbar(curr, total, full_progbar):
frac = curr/total
filled_progbar = round(frac*full_progbar)
print('\r', '#'*filled_progbar + '-'*(full_progbar-filled_progbar), '[{:>7.2%}]'.format(frac), end='')
def clear_folder(folder):
for the_file in os.listdir(folder):
file_path = os.path.join(folder, the_file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
#elif os.path.isdir(file_path): shutil.rmtree(file_path)
except Exception as e:
print(e)
def weights_init(m):
classname = m.__class__.__name__
# pdb.set_trace()
if classname.find('Conv') != -1:
m.weight.data.uniform_(-0.2, 0.2)
# pdb.set_trace()
elif classname.find('BatchNorm') != -1:
m.weight.data.uniform_(0.5, 1.5)
m.bias.data.fill_(0)