@@ -149,7 +149,7 @@ def test_type(self):
149
149
150
150
def test_predict (self ):
151
151
y_predicted = self .classifier .predict (self .x_test_iris [0 :1 ])
152
- y_expected = np .asarray ([[3.07686594e-16 , 2.23540978e-02 , 9.77645902e-01 ]])
152
+ y_expected = np .asarray ([[0.25544427 , 0.35099888 , 0.39355685 ]])
153
153
np .testing .assert_array_almost_equal (y_predicted , y_expected , decimal = 4 )
154
154
155
155
def test_save (self ):
@@ -298,9 +298,9 @@ def test_class_gradient_none_1(self):
298
298
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = None )
299
299
grad_expected = [
300
300
[
301
- [- 1.98021257 , 1.35627806 , - 6.28222561 , - 2.60076308 ],
302
- [- 0.56322294 , - 0.70427608 , - 0.98874801 , - 0.67053026 ],
303
- [0.6508137 , 0.26377308 , 1.54522324 , 0.80972391 ],
301
+ [- 1.97804999 , 1.35988402 , - 6.28209543 , - 2.59983373 ],
302
+ [- 0.56164223 , - 0.70078993 , - 0.98865014 , - 0.66950917 ],
303
+ [0.64962 , 0.2610305 , 1.54549754 , 0.80910802 ],
304
304
]
305
305
]
306
306
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 3 )
@@ -309,45 +309,60 @@ def test_class_gradient_none_2(self):
309
309
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = None )
310
310
grad_expected = [
311
311
[
312
- [- 1.98021257 , 1.35627806 , - 6.28222561 , - 2.60076308 ],
313
- [- 0.56322294 , - 0.70427608 , - 0.98874801 , - 0.67053026 ],
314
- [0.6508137 , 0.26377308 , 1.54522324 , 0.80972391 ],
312
+ [
313
+ - 1.97804999 ,
314
+ 1.35988402 ,
315
+ - 6.28209543 ,
316
+ - 2.59983397 ,
317
+ ],
318
+ [
319
+ - 0.56164235 ,
320
+ - 0.70078993 ,
321
+ - 0.98865038 ,
322
+ - 0.66950929 ,
323
+ ],
324
+ [
325
+ 0.64961988 ,
326
+ 0.26103044 ,
327
+ 1.5454973 ,
328
+ 0.8091079 ,
329
+ ],
315
330
],
316
331
[
317
- [- 1.92227495 , 1.34355378 , - 6.11815596 , - 2.52638054 ],
318
- [- 0.50528532 , - 0.71700042 , - 0.82467848 , - 0.59614766 ],
319
- [0.70875132 , 0.25104877 , 1.70929277 , 0.88410652 ],
332
+ [- 1.9202075 , 1.34698176 , - 6.1180439 , - 2.5255065 ],
333
+ [- 0.50379974 , - 0.71369207 , - 0.82459873 , - 0.59518182 ],
334
+ [0.70746249 , 0.24812828 , 1.70954895 , 0.88343531 ],
320
335
],
321
336
]
322
337
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 3 )
323
338
324
339
def test_class_gradient_int_1 (self ):
325
340
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = 1 )
326
- grad_expected = [[[- 0.56317311 , - 0.70493763 , - 0.98908609 , - 0.67106276 ]]]
341
+ grad_expected = [[[- 0.56164223 , - 0.70078993 , - 0.98865014 , - 0.66950917 ]]]
327
342
328
343
for i_shape in range (4 ):
329
344
self .assertAlmostEqual (grad_predicted [0 , 0 , i_shape ], grad_expected [0 ][0 ][i_shape ], 3 )
330
345
331
346
def test_class_gradient_int_2 (self ):
332
347
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = 1 )
333
348
grad_expected = [
334
- [[- 0.56317306 , - 0.70493776 , - 0.98908573 , - 0.67106259 ]],
335
- [[- 0.50522697 , - 0.71762568 , - 0.82497531 , - 0.5966416 ]],
349
+ [[- 0.56164235 , - 0.70078993 , - 0.98865038 , - 0.66950929 ]],
350
+ [[- 0.50379974 , - 0.71369207 , - 0.82459873 , - 0.59518182 ]],
336
351
]
337
352
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
338
353
339
354
def test_class_gradient_list_1 (self ):
340
355
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = [1 ])
341
- grad_expected = [[[- 0.56317311 , - 0.70493763 , - 0.98874801 , - 0.67106276 ]]]
356
+ grad_expected = [[[- 0.56164223 , - 0.70078993 , - 0.98865014 , - 0.66950917 ]]]
342
357
343
358
for i_shape in range (4 ):
344
359
self .assertAlmostEqual (grad_predicted [0 , 0 , i_shape ], grad_expected [0 ][0 ][i_shape ], 3 )
345
360
346
361
def test_class_gradient_list_2 (self ):
347
362
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = [1 , 2 ])
348
363
grad_expected = [
349
- [[- 0.56317306 , - 0.70493776 , - 0.98908573 , - 0.67106259 ]],
350
- [[0.70866591 , 0.25158876 , 1.70947325 , 0.88450021 ]],
364
+ [[- 0.56164235 , - 0.70078993 , - 0.98865038 , - 0.66950929 ]],
365
+ [[0.70746249 , 0.24812828 , 1.70954895 , 0.88343531 ]],
351
366
]
352
367
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 3 )
353
368
@@ -362,7 +377,7 @@ def test_class_gradient_label_wrong_type(self):
362
377
363
378
def test_loss_gradient (self ):
364
379
grad_predicted = self .classifier .loss_gradient (self .x_test_iris [0 :1 ], self .y_test_iris [0 :1 ])
365
- grad_expected = np .asarray ([[- 0.21690657 , - 0.08809226 , - 0.51512082 , - 0.27002635 ]])
380
+ grad_expected = np .asarray ([[- 0.21654 , - 0.08701016 , - 0.51516586 , - 0.26970267 ]])
366
381
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
367
382
368
383
def test_save (self ):
@@ -541,36 +556,36 @@ def test_class_gradient_none(self):
541
556
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = None )
542
557
grad_expected = [
543
558
[
544
- [- 0.34648966 , 1.63777444 , - 3.51845999 , - 1.4609451 ],
545
- [- 0.11198028 , - 2.51565392 , 0.71538245 , - 0.44830889 ],
546
- [- 0.38021886 , - 0.57562105 , 3.59966607 , 2.31772514 ],
559
+ [- 0.34659522 , 1.6376213 , - 3.51851979 , - 1.46078468 ],
560
+ [- 0.1121541 , - 2.51552211 , 0.71569165 , - 0.44883585 ],
561
+ [- 0.380205 , - 0.57552204 , 3.59972012 , 2.31760663 ],
547
562
]
548
563
]
549
564
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
550
565
551
566
def test_class_gradient_int_1 (self ):
552
567
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = 1 )
553
- grad_expected = [[[- 0.11198028 , - 2.51565392 , 0.71538245 , - 0.44830889 ]]]
568
+ grad_expected = [[[- 0.1121541 , - 2.51552211 , 0.71569165 , - 0.44883585 ]]]
554
569
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
555
570
556
571
def test_class_gradient_int_2 (self ):
557
572
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = 1 )
558
573
grad_expected = [
559
- [[- 0.11198028 , - 2.51565392 , 0.71538245 , - 0.44830889 ]],
560
- [[- 0.11198028 , - 2.51565392 , 0.71538245 , - 0.44830889 ]],
574
+ [[- 0.1121541 , - 2.51552211 , 0.71569165 , - 0.44883585 ]],
575
+ [[- 0.1121541 , - 2.51552211 , 0.71569165 , - 0.44883585 ]],
561
576
]
562
577
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
563
578
564
579
def test_class_gradient_list_1 (self ):
565
580
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = [1 ])
566
- grad_expected = [[[- 0.11198028 , - 2.51565392 , 0.71538245 , - 0.44830889 ]]]
581
+ grad_expected = [[[- 0.1121541 , - 2.51552211 , 0.71569165 , - 0.44883585 ]]]
567
582
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
568
583
569
584
def test_class_gradient_list_2 (self ):
570
585
grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = [1 , 2 ])
571
586
grad_expected = [
572
- [[- 0.11198028 , - 2.51565392 , 0.71538245 , - 0.44830889 ]],
573
- [[- 0.38021886 , - 0.57562105 , 3.59966607 , 2.31772514 ]],
587
+ [[- 0.1121541 , - 2.51552211 , 0.71569165 , - 0.44883585 ]],
588
+ [[- 0.380205 , - 0.57552204 , 3.59972012 , 2.31760663 ]],
574
589
]
575
590
np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
576
591
0 commit comments