-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepsilon_plot.py
94 lines (80 loc) · 2.01 KB
/
epsilon_plot.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import subprocess
import numpy as np
arglist=["python",
"attack.py",
"--classifier_name",
"fashion_polarized_model_epoch59",
"--model",
"Polarization_quantization_model",
"--num_restarts",
"20",
"--num_steps",
"100",
"--batch_size",
"5000",
"--eps",
"0.1",
"--step_size",
"0.01",
"--attack_method",
"pgd",
"--jump",
"0.2",
"--dataset",
"fashion"]
with open("./epsilon_fashion_bim_plain.txt", "a") as output:
for epsilon in np.arange(0,0.4,0.02):
output.write("\nepsilon = "+str(epsilon)+'\n')
output.flush()
arglist[13]=str(epsilon)
arglist[15]=str(epsilon/10)
subprocess.call(arglist, stdout=output);
arglist[7]=str(20)
arglist[9]=str(100)
with open("./epsilon_fashion_pgd_plain.txt", "a") as output:
for epsilon in np.arange(0,0.4,0.02):
output.write("\nepsilon = "+str(epsilon)+'\n')
output.flush()
arglist[13]=str(epsilon)
arglist[15]=str(epsilon/10)
subprocess.call(arglist, stdout=output);
arglist = [
"python",
"attack.py",
"--classifier_name",
"mnist_polarized_model_epoch59",
"--model",
"Polarization_quantization_model",
"--num_restarts",
"20",
"--num_steps",
"100",
"--batch_size",
"5000",
"--eps",
"0.3",
"--step_size",
"0.03",
"--attack_method",
"pgd",
"--jump",
"0.5",
"--dataset",
"mnist",
]
with open("./epsilon_mnist_bim_plain.txt", "a") as output:
for epsilon in np.arange(0, 0.4, 0.02):
output.write("\nepsilon = " + str(epsilon) + "\n")
output.flush()
arglist[13] = str(epsilon)
arglist[15] = str(epsilon / 10)
subprocess.call(arglist, stdout=output)
arglist[7] = str(20)
arglist[9] = str(100)
with open("./epsilon_mnist_pgd_plain.txt", "a") as output:
for epsilon in np.arange(0, 0.4, 0.02):
output.write("\nepsilon = " + str(epsilon) + "\n")
output.flush()
arglist[13] = str(epsilon)
arglist[15] = str(epsilon / 10)
subprocess.call(arglist, stdout=output)