File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ import robustml
2
+ import tensorflow as tf
3
+
4
+ import model
5
+
6
+ class Model (robustml .model .Model ):
7
+ def __init__ (self , sess ):
8
+ self ._model = model .Model ('eval' )
9
+
10
+ saver = tf .train .Saver ()
11
+ checkpoint = tf .train .latest_checkpoint ('models/model_0' )
12
+ saver .restore (sess , checkpoint )
13
+
14
+ self ._sess = sess
15
+ self ._input = self ._model .x_input
16
+ self ._logits = self ._model .pre_softmax
17
+ self ._predictions = self ._model .predictions
18
+ self ._dataset = robustml .dataset .CIFAR10 ()
19
+ self ._threat_model = robustml .threat_model .Linf (epsilon = 0.03 )
20
+
21
+ @property
22
+ def dataset (self ):
23
+ return self ._dataset
24
+
25
+ @property
26
+ def threat_model (self ):
27
+ return self ._threat_model
28
+
29
+ def classify (self , x ):
30
+ return self ._sess .run (self ._predictions ,
31
+ {self ._input : x })[0 ]
32
+
33
+ # expose attack interface
34
+
35
+ @property
36
+ def input (self ):
37
+ return self ._input
38
+
39
+ @property
40
+ def logits (self ):
41
+ return self ._logits
42
+
43
+ @property
44
+ def predictions (self ):
45
+ return self ._predictions
You can’t perform that action at this time.
0 commit comments