-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathcreatejobs-f1.py
74 lines (63 loc) · 2.14 KB
/
createjobs-f1.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python
# sample perl script to create SGE jobs (sun grid engine)
# for scanning a parameter space
import os
jobname = "F1_" # should be short
name = "" + jobname # name of shell scripts
res = "result_f1-EQLDIV"
submitfile = "submit_" + name + ".sh"
SUBMIT = open(submitfile,'w')
SUBMIT.write("#/bin/bash\n")
pwd=os.getcwd()
#number of epochs
e=10000
regstart = e/4
regend = e-e/20
i = 0
for l1 in [10**(-l1exp/10.0) for l1exp in range(35,60)]:
for l_n in [2,3]:
for normal in ([True] if i > 0 else [False, True]):
epochs = e if normal else 1
result = res + "/" if normal else res + "test/"
base_cmd = ["python src/mlfg_final.py -i ", str(i),
" -f ", result,
" -d data/f1-n-10k-1.dat.gz",
" --extrapol=data/f1-n-5k-1-test.dat.gz",
" --extrapol=data/f1-n-5k-1-2-test.dat.gz",
" --epochs=", str(epochs),
" --l1=", str(l1),
" --layers=", str(l_n),
" --iterNum=1",
" --reg_start=", str(regstart),
" --reg_end=", str(regend),
" -o",
]
cmd= "".join(base_cmd)
script_fname = ((name + str(i)) if normal else name + "000_test") + ".sh"
if normal:
SUBMIT.write("./" + script_fname + "\n")
with open(script_fname, 'w') as FILE:
FILE.write("""\
#!/bin/bash
# %(jobname)s%(i)d
cd %(pwd)s
export OMP_NUM_THREADS=1
export PATH=${HOME}/bin:/usr/bin:${PATH}
if %(cmd)s; then
rm -f %(script_fname)s
else
touch %(script_fname)s.dead
fi
""" % locals())
os.chmod(script_fname,0755)
i += 1
SUBMIT.close()
os.chmod(submitfile,0755)
print("Jobs:" , i)
with open("finished_" + name + ".sh",'w') as FINISHED:
FINISHED.write("#!/bin/bash\nset -e\n" +
'grep "#" $(ls ' + res + '/*.res -1 | head -n 1) >' + res + '/all.dat\n' +
"cat " + res + '/*.res | grep -v "#" >>' + res + '/all.dat\n' +
"cp " + __file__ + ' ' + res + '/\n' +
"rm finished_" + name+ '.sh ' + submitfile + '\n')
os.chmod("finished_" + name + ".sh",0755)