|
a |
|
b/tasks_base/generate.py |
|
|
1 |
'''Training script generator for subject-independent classification. |
|
|
2 |
''' |
|
|
3 |
with open('script.sh.template', 'r') as f: |
|
|
4 |
sh_template = f.read() |
|
|
5 |
with open('train.pbs.template', 'r') as f: |
|
|
6 |
pbs_template = f.read() |
|
|
7 |
|
|
|
8 |
|
|
|
9 |
def list_to_str(l): |
|
|
10 |
return ' '.join(map(str, l)) |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
all_folds = list(range(54)) |
|
|
14 |
command_template = "python train_base.py $datapath $outpath -fold {0} -gpu {1} > $logpath/stdout.f{0}.out &" |
|
|
15 |
for i, j in enumerate(range(0, len(all_folds), 8)): |
|
|
16 |
folds = all_folds[j:j+8] |
|
|
17 |
commands = [] |
|
|
18 |
for ind, fold in enumerate(folds): |
|
|
19 |
commands.append(command_template.format(fold, ind)) |
|
|
20 |
commands.append('wait') |
|
|
21 |
content = sh_template + '\n'.join(commands) |
|
|
22 |
with open('script.' + str(i) + '.sh', 'w') as f: |
|
|
23 |
f.write(content) |
|
|
24 |
content = pbs_template.format(i) |
|
|
25 |
with open('train.' + str(i) + '.pbs', 'w') as f: |
|
|
26 |
f.write(content) |