@@ -108,28 +108,28 @@ def test_4_tensorflow_mnist(self):
108108 x_test_adv = ead .generate (self .x_test_mnist , ** params )
109109 expected_x_test_adv = np .asarray (
110110 [
111- 0.45704955 ,
112- 0.43627003 ,
113- 0.57238287 ,
111+ 0.45284095 ,
112+ 0.43225235 ,
113+ 0.577448 ,
114114 1.0 ,
115- 0.11541145 ,
116- 0.12619308 ,
117- 0.48318917 ,
118- 0.3457903 ,
119- 0.17863746 ,
120- 0.09060935 ,
115+ 0.16554962 ,
116+ 0.3587564 ,
117+ 0.19202651 ,
118+ 0.04293771 ,
121119 0.0 ,
122- 0.00963121 ,
120+ 0.25811037 ,
123121 0.0 ,
124- 0.04749763 ,
125- 0.4058206 ,
126- 0.17860745 ,
122+ 0.0290696 ,
127123 0.0 ,
128- 0.9153206 ,
129- 0.84564775 ,
130- 0.20603634 ,
131- 0.10586322 ,
132- 0.00947509 ,
124+ 0.136172 ,
125+ 0.6153389 ,
126+ 0.12244645 ,
127+ 0.0 ,
128+ 0.7586619 ,
129+ 0.8366919 ,
130+ 0.22206311 ,
131+ 0.12455986 ,
132+ 0.02862802 ,
133133 0.0 ,
134134 0.0 ,
135135 0.0 ,
@@ -138,6 +138,7 @@ def test_4_tensorflow_mnist(self):
138138 0.0 ,
139139 ]
140140 )
141+ print (x_test_adv [0 , 14 , :, 0 ])
141142 np .testing .assert_array_almost_equal (x_test_adv [0 , 14 , :, 0 ], expected_x_test_adv , decimal = 6 )
142143 self .assertLessEqual (np .amax (x_test_adv ), 1.0 )
143144 self .assertGreaterEqual (np .amin (x_test_adv ), 0.0 )
@@ -213,28 +214,28 @@ def test_4_tensorflow_mnist(self):
213214 x_test_adv = ead_wob .generate (self .x_test_mnist , ** params )
214215 expected_x_test_adv = np .asarray (
215216 [
216- 0.3287169 ,
217- 0.31374657 ,
218- 0.42853343 ,
219- 0.8994576 ,
220- 0.19850709 ,
221- 0.11997936 ,
222- 0.5622535 ,
223- 0.43854535 ,
224- 0.19387433 ,
225- 0.12516324 ,
226- 0.0 ,
227- 0.10933565 ,
228- 0.02162433 ,
229- 0.07120894 ,
230- 0.95224255 ,
231- 0.3072921 ,
232- 0.48966524 ,
217+ 0.32568744 ,
218+ 0.31085464 ,
219+ 0.43235543 ,
233220 1.0 ,
234- 0.3814998 ,
235- 0.15782641 ,
236- 0.52283823 ,
237- 0.12852049 ,
221+ 0.2433605 ,
222+ 0.3411813 ,
223+ 0.49469775 ,
224+ 0.2603619 ,
225+ 0.0 ,
226+ 0.35584357 ,
227+ 0.0 ,
228+ 0.2046029 ,
229+ 0.0 ,
230+ 0.08249304 ,
231+ 1.0 ,
232+ 0.35813788 ,
233+ 0.62945133 ,
234+ 1.0 ,
235+ 0.32154015 ,
236+ 0.3497113 ,
237+ 0.7613426 ,
238+ 0.36533928 ,
238239 0.0 ,
239240 0.0 ,
240241 0.0 ,
@@ -243,6 +244,7 @@ def test_4_tensorflow_mnist(self):
243244 0.0 ,
244245 ]
245246 )
247+ print (x_test_adv [0 , 14 , :, 0 ])
246248 np .testing .assert_array_almost_equal (x_test_adv [0 , 14 , :, 0 ], expected_x_test_adv , decimal = 6 )
247249 self .assertLessEqual (np .amax (x_test_adv ), 1.0 )
248250 self .assertGreaterEqual (np .amin (x_test_adv ), 0.0 )
@@ -296,34 +298,34 @@ def test_9a_keras_mnist(self):
296298 x_test_adv = ead .generate (self .x_test_mnist , y = y_target )
297299 expected_x_test_adv = np .asarray (
298300 [
299- 0.0 ,
300- 0.0 ,
301- 0.0 ,
302- 0.0 ,
303- 0.0 ,
304- 0.0 ,
305- 0.0 ,
306- 0.0 ,
307- 0.0 ,
308- 0.0 ,
309- 0.00183569 ,
310- 0.0 ,
311- 0.0 ,
312- 0.49765405 ,
313- 1.0 ,
314- 0.6467149 ,
315- 0.0033755 ,
316- 0.0052456 ,
317- 0.0 ,
318- 0.01104407 ,
319- 0.00495547 ,
320- 0.02747423 ,
321- 0.0 ,
322- 0.0 ,
323- 0.0 ,
324- 0.0 ,
325- 0.0 ,
326- 0.0 ,
301+ 0.0000000e00 ,
302+ 0.0000000e00 ,
303+ 0.0000000e00 ,
304+ 0.0000000e00 ,
305+ 0.0000000e00 ,
306+ 0.0000000e00 ,
307+ 0.0000000e00 ,
308+ 0.0000000e00 ,
309+ 0.0000000e00 ,
310+ 7.8193319e-04 ,
311+ 5.5843666e-03 ,
312+ 0.0000000e00 ,
313+ 0.0000000e00 ,
314+ 4.9869284e-01 ,
315+ 1.0000000e00 ,
316+ 6.4663666e-01 ,
317+ 3.4855194e-03 ,
318+ 3.5087438e-03 ,
319+ 0.0000000e00 ,
320+ 9.8862723e-03 ,
321+ 3.8835173e-03 ,
322+ 3.0151173e-02 ,
323+ 0.0000000e00 ,
324+ 0.0000000e00 ,
325+ 0.0000000e00 ,
326+ 0.0000000e00 ,
327+ 0.0000000e00 ,
328+ 0.0000000e00 ,
327329 ]
328330 )
329331 np .testing .assert_array_almost_equal (x_test_adv [2 , 14 , :, 0 ], expected_x_test_adv , decimal = 6 )
@@ -371,28 +373,28 @@ def test_6_pytorch_mnist(self):
371373 x_test_adv = ead .generate (x_test , ** params )
372374 expected_x_test_adv = np .asarray (
373375 [
374- 0.01678124 ,
376+ 0.01758931 ,
375377 0.0 ,
376378 0.0 ,
377379 0.0 ,
378380 0.0 ,
379381 0.0 ,
380382 0.0 ,
381383 0.0 ,
382- 0.00665895 ,
384+ 0.00698278 ,
383385 0.0 ,
384- 0.11374763 ,
385- 0.36250514 ,
386- 0.5472948 ,
387- 0.9308808 ,
386+ 0.11318438 ,
387+ 0.36223832 ,
388+ 0.54720753 ,
389+ 0.93125045 ,
388390 1.0 ,
389- 0.99920374 ,
390- 0.86274165 ,
391- 0.6346757 ,
392- 0.5597227 ,
393- 0.24191494 ,
391+ 0.9999359 ,
392+ 0.8638486 ,
393+ 0.6354147 ,
394+ 0.5600332 ,
395+ 0.24081531 ,
394396 0.25882354 ,
395- 0.0091916 ,
397+ 0.00899846 ,
396398 0.0 ,
397399 0.0 ,
398400 0.0 ,
@@ -401,6 +403,7 @@ def test_6_pytorch_mnist(self):
401403 0.0 ,
402404 ]
403405 )
406+ print (x_test_adv [2 , 0 , :, 14 ])
404407 np .testing .assert_array_almost_equal (x_test_adv [2 , 0 , :, 14 ], expected_x_test_adv , decimal = 6 )
405408 self .assertLessEqual (np .amax (x_test_adv ), 1.0 )
406409 self .assertGreaterEqual (np .amin (x_test_adv ), 0.0 )
@@ -429,7 +432,7 @@ def test_8_keras_iris_clipped(self):
429432 classifier = get_tabular_classifier_kr ()
430433 attack = ElasticNet (classifier , targeted = False , max_iter = 10 , verbose = False )
431434 x_test_adv = attack .generate (self .x_test_iris )
432- expected_x_test_adv = np .asarray ([0.860373 , 0.455002 , 0.654925 , 0.240258 ])
435+ expected_x_test_adv = np .asarray ([0.8670352 , 0.4624909 , 0.6453267 , 0.23096858 ])
433436 np .testing .assert_array_almost_equal (x_test_adv [0 , :], expected_x_test_adv , decimal = 6 )
434437 self .assertLessEqual (np .amax (x_test_adv ), 1.0 )
435438 self .assertGreaterEqual (np .amin (x_test_adv ), 0.0 )
@@ -498,7 +501,7 @@ def test_9_keras_iris_unbounded(self):
498501 classifier = KerasClassifier (model = classifier ._model , use_logits = False , channels_first = True )
499502 attack = ElasticNet (classifier , targeted = False , max_iter = 10 , verbose = False )
500503 x_test_adv = attack .generate (self .x_test_iris )
501- expected_x_test_adv = np .asarray ([0.860373 , 0.455002 , 0.654925 , 0.240258 ])
504+ expected_x_test_adv = np .asarray ([0.8670352 , 0.4624909 , 0.6453267 , 0.23096858 ])
502505 np .testing .assert_array_almost_equal (x_test_adv [0 , :], expected_x_test_adv , decimal = 6 )
503506 predictions_adv = np .argmax (classifier .predict (x_test_adv ), axis = 1 )
504507 np .testing .assert_array_equal (
@@ -564,8 +567,10 @@ def test_3_tensorflow_iris(self):
564567 # Test untargeted attack
565568 attack = ElasticNet (classifier , targeted = False , max_iter = 10 , verbose = False )
566569 x_test_adv = attack .generate (self .x_test_iris )
567- expected_x_test_adv = np .asarray ([0.852286 , 0.434626 , 0.703376 , 0.293738 ])
570+ expected_x_test_adv = np .asarray ([0.84810126 , 0.43320203 , 0.70404345 , 0.29160658 ])
571+ print (x_test_adv [0 , :])
568572 np .testing .assert_array_almost_equal (x_test_adv [0 , :], expected_x_test_adv , decimal = 6 )
573+ print (np .amax (x_test_adv ))
569574 self .assertLessEqual (np .amax (x_test_adv ), 1.0 )
570575 self .assertGreaterEqual (np .amin (x_test_adv ), 0.0 )
571576
@@ -629,7 +634,8 @@ def test_3_tensorflow_iris(self):
629634 targets = random_targets (self .y_test_iris , nb_classes = 3 )
630635 attack = ElasticNet (classifier , targeted = True , max_iter = 10 , verbose = False )
631636 x_test_adv = attack .generate (self .x_test_iris , ** {"y" : targets })
632- expected_x_test_adv = np .asarray ([0.892806 , 0.531875 , 0.501707 , 0.059951 ])
637+ expected_x_test_adv = np .asarray ([0.88713187 , 0.5239736 , 0.49900988 , 0.05677444 ])
638+ print (x_test_adv [0 , :])
633639 np .testing .assert_array_almost_equal (x_test_adv [0 , :], expected_x_test_adv , decimal = 6 )
634640 self .assertLessEqual (np .amax (x_test_adv ), 1.0 )
635641 self .assertGreaterEqual (np .amin (x_test_adv ), 0.0 )
@@ -699,7 +705,8 @@ def test_5_pytorch_iris(self):
699705 classifier = get_tabular_classifier_pt ()
700706 attack = ElasticNet (classifier , targeted = False , max_iter = 10 , verbose = False )
701707 x_test_adv = attack .generate (self .x_test_iris .astype (np .float32 ))
702- expected_x_test_adv = np .asarray ([0.852286 , 0.434626 , 0.703376 , 0.293738 ])
708+ expected_x_test_adv = np .asarray ([0.84810126 , 0.43320203 , 0.70404345 , 0.29160658 ])
709+ print (x_test_adv [0 , :])
703710 np .testing .assert_array_almost_equal (x_test_adv [0 , :], expected_x_test_adv , decimal = 6 )
704711 self .assertLessEqual (np .amax (x_test_adv ), 1.0 )
705712 self .assertGreaterEqual (np .amin (x_test_adv ), 0.0 )
0 commit comments