-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmulti_processor.py
48 lines (39 loc) · 1.44 KB
/
multi_processor.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
multiprocess script for each target domain
"""
import os,sys
from multiprocessing import Pool
def multi_run_wrapper(args):
return run_process(*args)
def run_process(target,k,src_train,rescale):
# os.system('time python att_model.py %s'%(target))
print 'time python att_model.py %s %d %f %d'%(target,k,src_train,rescale)
os.system('time python att_model.py %s %d %f %d'%(target,k,src_train,rescale))
# os.system('time python exam_stars.py %s %d 0.5 dsc'%(target,k))
pass
def main(target,src_train=0,rescale=0):
processes = []
ks = [0,5,10,30,50,70,100,200]
# ks = [5,10,30,50,70,100,200]
# ks = [100,500,1000,2000,3000,4000]
for k in ks:
processes.append((target,k,src_train,rescale))
pool = Pool(processes=4)
pool.map(multi_run_wrapper, processes)
pass
if __name__ == '__main__':
if len(sys.argv) > 3:
target = sys.argv[1]
print target
src_train = float(sys.argv[2])
rescale = int(sys.argv[3])
print "src_train",src_train
print "rescale",rescale
print "##############################"
main(target,src_train,rescale)
elif len(sys.argv) >1:
target = sys.argv[1]
print target
main(target)
else:
print "usage: <target> or <target,src_train,rescale>"