-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_args.py
37 lines (31 loc) · 1.25 KB
/
gen_args.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
import itertools
import sys
batch = sys.argv[1] if len(sys.argv)>1 else ''
OPTS = []
if batch == '':
OUT_FILE = 'args/base.txt'
opts = {'epochs': [80001], 'manifold': ['Euclidean','PoincareBall'], 'w_pde':[1e-16, 1e+3], 'w_gpde': [0., 1e+9] }
OPTS.append(opts)
opts = {'epochs': [80001], 'manifold': ['PoincareBall'], 'v_max':[.01,.1,1.]}
OPTS.append(opts)
elif batch == 'var':
OUT_FILE = 'args/var.txt'
opts = {'v_scaler': [1e-0, 1e-1, 1e-2, 1e-3, 1e-4], 'path': ['993_c1']}
else:
print('argv[1] not recognized!')
raise
print(f'out file: {OUT_FILE}')
if __name__ == '__main__':
### take the cartesian product of all opts and write
### arg strings (e.g. --model MLP --dropout 0.6 ...) to file
#OUT_FILE = sys.argv[1] if len(sys.argv)>1 else 'args.txt'
if len(OPTS)==0:
vals = list(itertools.product(*opts.values()))
args = [''.join([f'--{k} {str(v[i])} ' for i,k in enumerate(opts)]) for v in vals]
elif len(OPTS)>0:
vals = []
args = []
for opts in OPTS:
vals = list(itertools.product(*opts.values()))
args += [''.join([f'--{k} {str(v[i])} ' for i,k in enumerate(opts)]) for v in vals]
with open(OUT_FILE,'w') as fp: fp.write('\n'.join(args))