-
Notifications
You must be signed in to change notification settings - Fork 14
/
benchmark_gen.py
67 lines (56 loc) · 2.68 KB
/
benchmark_gen.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
"""poisoning-benchmark runscript creator."""
# ######## BREW POISONS ####################
file_name = 'poison_brewing'
benchmark_file = f'benchmark_{file_name}.sh'
experiments = []
def _command(idx, name, ensemble, model, add_options):
setup = f'--name bm_{name} --benchmark poisons/poison_setups_from_scratch.pickle --save benchmark --vruns 0'
return f'python brew_poison.py {setup} --ensemble {ensemble} --net {model} {add_options} --eps 8 --benchmark_idx {idx}'
with open(benchmark_file, 'w+') as file:
source_model = 'ResNet18'
add_options = ''
ensemble = 1
experiment_name = 'base'
experiments.append((experiment_name, source_model))
for i in range(100):
file.write(_command(i, experiment_name, ensemble, source_model, add_options) + '\n')
# source_model = 'ResNet18'
# add_options = '--gradient_noise 0.001'
# ensemble = 1
# experiment_name = 'private'
# experiments.append((experiment_name, source_model))
# for i in range(100):
# file.write(_command(i, experiment_name, ensemble, source_model, add_options) + '\n')
source_model = 'ResNet18'
add_options = ''
ensemble = 4
experiment_name = 'ens4'
experiments.append((experiment_name, source_model))
for i in range(100):
file.write(_command(i, experiment_name, ensemble, source_model, add_options) + '\n')
source_model = 'ResNet18,VGG11,MobileNetV2'
add_options = '--pbatch 128 --tau 0.5'
ensemble = 6
experiment_name = 'het'
experiments.append((experiment_name, source_model))
for i in range(100):
file.write(_command(i, experiment_name, ensemble, source_model, add_options) + '\n')
# source_model = 'ResNet18'
# add_options = ''
# ensemble = 8
# experiment_name = 'ens8'
# experiments.append((experiment_name, source_model))
# for i in range(100):
# file.write(_command(i, experiment_name, ensemble, source_model, add_options) + '\n')
# ######## BENCHMARK POISONS ################################################
file_name = 'poison_evaluation'
benchmark_file = f'benchmark_{file_name}.sh'
def _command(idx, name, brew_model, eval_model):
folder_name = f'bm_{name}_{brew_model}'
setup = f"--poisons_path poisons/benchmark_results/{folder_name}/{idx} --from_scratch --model {eval_model} --output bm_{folder_name}_{eval_model}"
return f'python ../poisoning-benchmark/benchmark_test.py {setup}'
with open(benchmark_file, 'w+') as file:
for (experiment_name, source_model) in experiments:
for i in range(100):
for eval_model in ['ResNet18', 'VGG11', 'MobileNetV2']:
file.write(_command(i, experiment_name, '_'.join(source_model.split(',')), eval_model) + '\n')