Esempio n. 1
0
 def test_sparse_categorical_crossentropy_average_loss_false_weights_torch(
         self):
     obj1 = sparse_categorical_crossentropy(
         y_pred=self.torch_pred,
         y_true=self.torch_true,
         average_loss=False,
         class_weights=self.torch_weights).numpy()
     obj2 = np.array([2.3025851, 5.9914646, 2.3025851])
     self.assertTrue(np.allclose(obj1, obj2))
Esempio n. 2
0
 def test_sparse_categorical_crossentropy_average_loss_false_torch(self):
     obj1 = sparse_categorical_crossentropy(y_pred=self.torch_pred,
                                            y_true=self.torch_true,
                                            average_loss=False).numpy()
     obj2 = np.array([2.3025851, 2.9957323, 2.3025851])
     self.assertTrue(np.allclose(obj1, obj2))
Esempio n. 3
0
 def test_sparse_categorical_crossentropy_average_loss_true_torch(self):
     obj1 = sparse_categorical_crossentropy(y_pred=self.torch_pred,
                                            y_true=self.torch_true).numpy()
     obj2 = 2.5336342
     self.assertTrue(np.allclose(obj1, obj2))