-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_base.py
46 lines (28 loc) · 1.28 KB
/
test_base.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
# -*- coding: utf-8 -*-
"""
@author: Abderrahmen Amich
@email: aamich@umich.edu
"""
from absl import app, flags
from mtd import test_base
from sys import argv, exit, stderr
if __name__ == "__main__":
#### User configuration ####
if len(argv) < 3 or len(argv) > 5:
print('Use: {} [data_name] [attack] [batch_size=128] [epsilon=0.3] '.format(argv[0]), file=stderr)
exit(1)
elif len(argv) >= 3:
flags.DEFINE_string("data", argv[1], "used dataset.")
flags.DEFINE_string("attack", argv[2], "evasion attack.")
flags.DEFINE_integer("test_set", 5000, "test set size.")
flags.DEFINE_integer("class_nb", 10, "Number of labels.")
if len(argv) == 3:
flags.DEFINE_integer("batch", 128, "batch size.")
flags.DEFINE_float("eps", 0.3, "Total epsilon for attacks.")
elif len(argv) == 4:
flags.DEFINE_integer("batch",argv[3] , "batch size.")
flags.DEFINE_float("eps", 0.3, "Total epsilon for attacks.")
elif len(argv) == 5:
flags.DEFINE_integer("batch",argv[3] , "batch size.")
flags.DEFINE_float("eps", argv[4], "Total epsilon for attacks.")
app.run(test_base)