This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
single_run.py
63 lines (44 loc) · 1.82 KB
/
single_run.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
import os
import time
import multiprocessing
import moxing as mox
import numpy as np
dataset = 'cifar10'
mox.file.copy_parallel('s3://bucket-london2/DATASETS/' + dataset.upper(),'/cache/test')
os.system('rm -r *')
base_name = '4444_final_cifar10_v1'
def single_run(seed, gpu):
n_layers1 = 14
n_layers2 = 20
n_epochs1 = 76
name = base_name + '_v' + str(gpu)
os.system('python /cache/code/search.py --name {} --dataset {} --layers {} --epochs {} --seed {} --gpus {} --drop_rate 0.00003'
.format(name, dataset, n_layers1, n_epochs1, seed, gpu))
with open(os.path.join('searchs', name,'genotype.txt'), 'r') as f:
genotype = f.read()
os.system('python /cache/code/augment.py --name {} --dataset {} --seed {} --gpus {} --genotype "{}"'.
format(name, dataset, seed, gpu, genotype))
if __name__ == '__main__':
processes = []
for i in range(8):
p = multiprocessing.Process(target=single_run, args=(i, i))
processes.append(p)
p.start()
for p in processes:
p.join()
accs = []
res_file = 'result_' + base_name + '.txt'
with open(res_file, 'w') as res:
for i in range(8):
name = base_name + '_v' + str(i)
with open(os.path.join('searchs', name, 'genotype.txt'), 'r') as f:
genotype = f.read()
with open(os.path.join('augments', name, name + '.log')) as f:
lines = f.readlines()
acc = lines[-1][-9:-3]
accs.append(float(acc))
res.write('{}\t{}\n'.format(acc, genotype))
mean = np.mean(accs)
std = np.std(accs)
res.write('mean: {:.2f}\tstd: {:.2f}\n'.format(mean, std))
mox.file.copy_parallel(res_file, os.path.join('s3://bucket-auto2/hongweijun/archive2/', res_file))