@@ -203,16 +203,16 @@ def test_type(self):
203203
204204 def test_predict (self ):
205205 y_predicted = self .classifier .predict (self .x_test_iris [0 :1 ])
206- y_expected = np .asarray ([[0.07809449 , 0.36258262 , 0.55932295 ]])
206+ y_expected = np .asarray ([[0.07997696 , 0.36272544 , 0.5572976 ]])
207207 np .testing .assert_array_almost_equal (y_predicted , y_expected , decimal = 4 )
208208
209209 def test_class_gradient_none_1 (self ):
210210 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = None )
211211 grad_expected = [
212212 [
213- [- 1.97934151 , 1.36346793 , - 6.29719639 , - 2.61386204 ],
214- [- 0.56940532 , - 0.71100581 , - 1.00625587 , - 0.68006182 ],
215- [0.64548057 , 0.27053964 , 1.5315429 , 0.80580771 ],
213+ [- 1.98016214 , 1.35561633 , - 6.28256321 , - 2.60129547 ],
214+ [- 0.56317347 , - 0.70493793 , - 0.98908591 , - 0.67106223 ],
215+ [0.65072 , 0.2642768 , 1.54536295 , 0.81007898 ],
216216 ]
217217 ]
218218 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
@@ -221,45 +221,46 @@ def test_class_gradient_none_2(self):
221221 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = None )
222222 grad_expected = [
223223 [
224- [- 1.97934151 , 1.36346793 , - 6.29719639 , - 2.61386204 ],
225- [- 0.56940532 , - 0.71100581 , - 1.00625587 , - 0.68006182 ],
226- [0.64548057 , 0.27053964 , 1.5315429 , 0.80580771 ],
224+ [- 1.98016214 , 1.35561633 , - 6.28256369 , - 2.60129547 ],
225+ [- 0.56317353 , - 0.70493793 , - 0.98908603 , - 0.67106229 ],
226+ [0.65071994 , 0.2642768 , 1.54536283 , 0.81007892 ],
227227 ],
228228 [
229- [- 1.92147708 , 1.3512013 , - 6.13324356 , - 2.53924561 ],
230- [- 0.51154077 , - 0.72327244 , - 0.84230322 , - 0.60544527 ],
231- [0.70334512 , 0.25827295 , 1.69549561 , 0.88042426 ],
229+ [- 1.92221594 , 1.34292829 , - 6.11845303 , - 2.5268743 ],
230+ [- 0.50522733 , - 0.71762598 , - 0.82497525 , - 0.59664112 ],
231+ [0.70866615 , 0.25158882 , 1.70947361 , 0.88450009 ],
232232 ],
233233 ]
234234 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
235235
236236 def test_class_gradient_int_1 (self ):
237237 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = 1 )
238- grad_expected = [[[- 0.56940532 , - 0.71100581 , - 1.00625587 , - 0.68006182 ]]]
238+ grad_expected = [[[- 0.56317347 , - 0.70493793 , - 0.98908591 , - 0.67106223 ]]]
239239
240240 for i_shape in range (4 ):
241241 self .assertAlmostEqual (grad_predicted [0 , 0 , i_shape ], grad_expected [0 ][0 ][i_shape ], 3 )
242242
243243 def test_class_gradient_int_2 (self ):
244244 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = 1 )
245245 grad_expected = [
246- [[- 0.56940532 , - 0.71100581 , - 1.00625587 , - 0.68006182 ]],
247- [[- 0.51154077 , - 0.72327244 , - 0.84230322 , - 0.60544527 ]],
246+ [[- 0.56317353 , - 0.70493793 , - 0.98908603 , - 0.67106229 ]],
247+ [[- 0.50522733 , - 0.71762598 , - 0.82497525 , - 0.59664112 ]],
248248 ]
249249 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
250250
251251 def test_class_gradient_list_1 (self ):
252252 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = [1 ])
253- grad_expected = [[[- 0.56940532 , - 0.71100581 , - 1.00625587 , - 0.68006182 ]]]
253+ grad_expected = [[[- 0.56317347 , - 0.70493793 , - 0.98908591 , - 0.67106223 ]]]
254+ print (grad_predicted )
254255
255256 for i_shape in range (4 ):
256257 self .assertAlmostEqual (grad_predicted [0 , 0 , i_shape ], grad_expected [0 ][0 ][i_shape ], 3 )
257258
258259 def test_class_gradient_list_2 (self ):
259260 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = [1 , 2 ])
260261 grad_expected = [
261- [[- 0.56940532 , - 0.71100581 , - 1.00625587 , - 0.68006182 ]],
262- [[0.70334512 , 0.25827295 , 1.69549561 , 0.88042426 ]],
262+ [[- 0.56317353 , - 0.70493793 , - 0.98908603 , - 0.67106229 ]],
263+ [[0.70866615 , 0.25158882 , 1.70947361 , 0.88450009 ]],
263264 ]
264265 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
265266
@@ -274,7 +275,7 @@ def test_class_gradient_label_wrong_type(self):
274275
275276 def test_loss_gradient (self ):
276277 grad_predicted = self .classifier .loss_gradient (self .x_test_iris [0 :1 ], self .y_test_iris [0 :1 ])
277- grad_expected = np .asarray ([[- 0.21516019 , - 0.09017988 , - 0.51051431 , - 0.26860258 ]])
278+ grad_expected = np .asarray ([[- 0.21690667 , - 0.08809228 , - 0.51512096 , - 0.27002633 ]])
278279 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
279280
280281
@@ -304,7 +305,7 @@ def test_type(self):
304305 def test_class_gradient (self ):
305306 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = None )
306307 grad_expected = np .asarray (
307- [[[- 0.1428355 , 0.12111039 , - 0.45059183 , - 0.17579888 ], [0.1428355 , - 0.12111039 , 0.45059183 , 0.17579888 ]]]
308+ [[[- 0.14551339 , 0.12298754 , - 0.45839342 , - 0.17835225 ], [0.14551339 , - 0.12298754 , 0.45839342 , 0.17835225 ]]]
308309 )
309310 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 3 )
310311
@@ -318,7 +319,7 @@ def test_loss_gradient(self):
318319 ][:, [0 , 1 ]]
319320
320321 grad_predicted = self .classifier .loss_gradient (x_test_binary [0 :1 ], y_test_binary [0 :1 ])
321- grad_expected = np .asarray ([[- 0.37461641 , 0.31763777 , - 1.18177287 , - 0.4610699 ]])
322+ grad_expected = np .asarray ([[- 0.3771413 , 0.31875887 , - 1.18806318 , - 0.46225301 ]])
322323 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
323324
324325
@@ -342,16 +343,16 @@ def test_predict(self):
342343
343344 def test_loss_gradient (self ):
344345 grad_predicted = self .classifier .loss_gradient (self .x_test_iris [0 :1 ], self .y_test_iris [0 :1 ])
345- grad_expected = np .asarray ([[- 2.8753524 , 0.31140438 , - 7.889445 , - 3.8314016 ]])
346+ grad_expected = np .asarray ([[- 2.9100819 , 0.3048792 , - 7.935282 , - 3.840562 ]])
346347 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
347348
348349 def test_class_gradient_none_1 (self ):
349350 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = None )
350351 grad_expected = [
351352 [
352- [- 1.52398277 , 1.6984953 , - 6.05832438 , - 2.45788848 ],
353- [- 0.43530558 , - 1.38692786 , 0.41607214 , - 0.15109791 ],
354- [1.95928835 , - 0.31156744 , 5.64225224 , 2.6089864 ],
353+ [- 1.5939425 , 1.67301144 , - 6.15095666 , - 2.4862934 ],
354+ [- 0.40469415 , - 1.37572607 , 0.46867108 , - 0.13317975 ],
355+ [1.99863665 , - 0.29728537 , 5.68228559 , 2.61947315 ],
355356 ]
356357 ]
357358 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
@@ -360,41 +361,41 @@ def test_class_gradient_none_2(self):
360361 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = None )
361362 grad_expected = [
362363 [
363- [- 1.52398277 , 1.6984953 , - 6.05832438 , - 2.45788848 ],
364- [- 0.43530558 , - 1.38692786 , 0.41607214 , - 0.15109791 ],
365- [1.95928835 , - 0.31156744 , 5.64225224 , 2.6089864 ],
364+ [- 1.5939425 , 1.67301144 , - 6.15095666 , - 2.4862934 ],
365+ [- 0.40469415 , - 1.37572607 , 0.46867108 , - 0.13317975 ],
366+ [1.99863665 , - 0.29728537 , 5.68228559 , 2.61947315 ],
366367 ],
367368 [
368- [- 1.52592969 , 1.67535916 , - 6.2138464 , - 2.57887417 ],
369- [- 0.43875292 , - 1.38381583 , 0.48486185 , - 0.1011285 ],
370- [1.96468261 , - 0.29154334 , 5.72898455 , 2.68000267 ],
369+ [- 1.5962279 , 1.64964639 , - 6.30453897 , - 2.60572715 ],
370+ [- 0.40788449 , - 1.37232544 , 0.53680777 , - 0.08368929 ],
371+ [2.00411239 , - 0.27732096 , 5.7677312 , 2.68941644 ],
371372 ],
372373 ]
373374 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
374375
375376 def test_class_gradient_int_1 (self ):
376377 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = 1 )
377- grad_expected = [[[- 0.43530558 , - 1.38692786 , 0.41607214 , - 0.15109791 ]]]
378+ grad_expected = [[[- 0.40469415 , - 1.37572607 , 0.46867108 , - 0.13317975 ]]]
378379 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
379380
380381 def test_class_gradient_int_2 (self ):
381382 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = 1 )
382383 grad_expected = [
383- [[- 0.43530558 , - 1.38692786 , 0.41607214 , - 0.15109791 ]],
384- [[- 0.43875292 , - 1.38381583 , 0.48486185 , - 0.1011285 ]],
384+ [[- 0.40469415 , - 1.37572607 , 0.46867108 , - 0.13317975 ]],
385+ [[- 0.40788449 , - 1.37232544 , 0.53680777 , - 0.08368929 ]],
385386 ]
386387 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
387388
388389 def test_class_gradient_list_1 (self ):
389390 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = [1 ])
390- grad_expected = [[[- 0.43530558 , - 1.38692786 , 0.41607214 , - 0.15109791 ]]]
391+ grad_expected = [[[- 0.40469415 , - 1.37572607 , 0.46867108 , - 0.13317975 ]]]
391392 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
392393
393394 def test_class_gradient_list_2 (self ):
394395 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :2 ], label = [1 , 2 ])
395396 grad_expected = [
396- [[- 0.43530558 , - 1.38692786 , 0.41607214 , - 0.15109791 ]],
397- [[1.96468261 , - 0.29154334 , 5.72898455 , 2.68000267 ]],
397+ [[- 0.40469415 , - 1.37572607 , 0.46867108 , - 0.13317975 ]],
398+ [[2.00411239 , - 0.27732096 , 5.7677312 , 2.68941644 ]],
398399 ]
399400 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
400401
@@ -427,16 +428,16 @@ def test_predict(self):
427428
428429 def test_loss_gradient (self ):
429430 grad_predicted = self .classifier .loss_gradient (self .x_test_iris [0 :1 ], self .y_test_iris [0 :1 ])
430- grad_expected = np .asarray ([[0.38537693 , 0.5659405 , - 3.600912 , - 2.338979 ]])
431+ grad_expected = np .asarray ([[0.38021886 , 0.57562107 , - 3.599666 , - 2.3177252 ]])
431432 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
432433
433434 def test_class_gradient (self ):
434435 grad_predicted = self .classifier .class_gradient (self .x_test_iris [0 :1 ], label = None )
435436 grad_expected = [
436437 [
437- [- 0.34997019 , 1.61489704 , - 3.49002061 , - 1.46298544 ],
438- [- 0.11249995 , - 2.52947052 , 0.7052329 , - 0.44872424 ],
439- [- 0.3853818 , - 0.5659519 , 3.60090744 , 2.33898192 ],
438+ [- 0.34648966 , 1.63777444 , - 3.51845999 , - 1.4609451 ],
439+ [- 0.11198028 , - 2.51565392 , 0.71538245 , - 0.44830889 ],
440+ [- 0.38021886 , - 0.57562105 , 3.59966607 , 2.31772514 ],
440441 ]
441442 ]
442443 np .testing .assert_array_almost_equal (grad_predicted , grad_expected , decimal = 4 )
0 commit comments