Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
theyoucheng committed Oct 23, 2021
1 parent a30e5dd commit 017cc7d
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 3 deletions.
Binary file added data/gtsrb/10009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/gtsrb/10069.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/gtsrb/3491.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/gtsrb/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/gtsrb/7300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/gtsrb_backdoor.h5
Binary file not shown.
7 changes: 5 additions & 2 deletions src/deepcover.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def main():
parser.add_argument("--outputs", dest="outputs", default="outs",
help="the outputput test data directory", metavar="DIR")
parser.add_argument("--measures", dest="measures", default=['tarantula', 'zoltar', 'ochiai', 'wong-ii'],
help="the measures", metavar="zoltar, tarantula ...", nargs='+')
help="the SFL measures (tarantula, zoltar, ochiai, wong-ii)", metavar="" , nargs='+')
parser.add_argument("--measure", dest="measure", default="None",
help="the measure", metavar="zoltar, tarantula ...")
help="the SFL measure", metavar="MEASURE")
parser.add_argument("--mnist-dataset", dest="mnist", help="MNIST dataset", action="store_true")
parser.add_argument("--normalized-input", dest="normalized", help="To normalize the input", action="store_true")
parser.add_argument("--cifar10-dataset", dest="cifar10", help="CIFAR-10 dataset", action="store_true")
Expand All @@ -42,6 +42,8 @@ def main():
help="input cols", metavar="INT")
parser.add_argument("--input-channels", dest="img_channels", default="3",
help="input channels", metavar="INT")
parser.add_argument("--x-verbosity", dest="x_verbosity", default="0",
help="the verbosity level of explanation output", metavar="INT")
parser.add_argument("--top-classes", dest="top_classes", default="1",
help="check the top-xx classifications", metavar="INT")
parser.add_argument("--adversarial-ub", dest="adv_ub", default="1.",
Expand Down Expand Up @@ -126,6 +128,7 @@ def main():
eobj.attack=args.attack
eobj.text_only=args.text_only
eobj.normalized=args.normalized
eobj.x_verbosity=int(args.x_verbosity)
eobj.fnames=fnames
measures = []
if not args.measure=='None':
Expand Down
5 changes: 4 additions & 1 deletion src/to_explain.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
import numpy as np
from spectra_gen import *
from to_rank import *
Expand Down Expand Up @@ -27,6 +28,7 @@ def to_explain(eobj):
reasonable_advs=False
while ite<eobj.testgen_iter:
print (' #### [Start generating SFL spectra...]')
start=time.time()
ite+=1

passing, failing=spectra_sym_gen(eobj, x, y[-1:], adv_value=eobj.adv_value, testgen_factor=eobj.testgen_factor, testgen_size=eobj.testgen_size)
Expand All @@ -44,7 +46,8 @@ def to_explain(eobj):

adv_part=num_advs*1./tot
#print ('###### adv_percentage:', adv_part, num_advs, tot)
print (' #### [SFL spectra generation DONE: passing {0} / failing {1}, total {2}]'.format(1-adv_part, adv_part, tot))
end=time.time()
print (' #### [SFL spectra generation DONE: passing {0:.2f} / failing {1:.2f}, total {2}; time: {3:.2f} seconds]'.format(1-adv_part, adv_part, tot, end-start))

if adv_part<=eobj.adv_lb:
print (' #### [too few failing tests: SFL explanation aborts]')
Expand Down
2 changes: 2 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, model, inputs):
self.text_only=None
self.measures=None
self.normalized=None
self.x_verbosity=None
self.fnames=[]


Expand Down Expand Up @@ -113,5 +114,6 @@ def top_plot(sbfl_element, ind, di, metric='', eobj=None, bg=128, online=False,
if y==sbfl_element.y and not found_exp:
save_an_image(im_o, 'explanation-found-{1}-{0}'.format(int(count/base), metric), di)
found_exp = True
if eobj.x_verbosity>0: return
pos-=1

0 comments on commit 017cc7d

Please sign in to comment.