Exemplo n.º 1
0
 def test_duplicate_non_winner(self):
     softmax_values = np.array([[0.1, 0.8, 0.05, 0.05],
                                [0.2, 0.09, 0.7, 0.01]])
     prediction, softmax = MaxSoftmax.calculate(softmax_values)
     self.assertEqual((2, ), prediction.shape)
     self.assertEqual((2, ), softmax.shape)
     self.assertEqual(1, prediction[0])
     self.assertAlmostEqual(0.8, softmax[0])
     self.assertEqual(2, prediction[1])
     self.assertAlmostEqual(0.7, softmax[1])
Exemplo n.º 2
0
 def test_happy_path_batch(self):
     softmax_values = np.array([[0.1, 0.8, 0.08, 0.02],
                                [0.1, 0.8, 0.08, 0.02],
                                [0.2, 0.09, 0.7, 0.01]])
     prediction, softmax = MaxSoftmax.calculate(softmax_values)
     self.assertEqual((3, ), prediction.shape)
     self.assertEqual((3, ), softmax.shape)
     self.assertEqual(1, prediction[0])
     self.assertAlmostEqual(0.8, softmax[0])
     self.assertEqual(1, prediction[1])
     self.assertAlmostEqual(0.8, softmax[1])
     self.assertEqual(2, prediction[2])
     self.assertAlmostEqual(0.7, softmax[2])
Exemplo n.º 3
0
 def test_duplicate_winner(self):
     softmax_values = np.array([[0.4, 0.4, 0.1, 0.1],
                                [0.2, 0.09, 0.7, 0.01]])
     prediction, softmax = MaxSoftmax.calculate(softmax_values)
     self.assertEqual((2, ), prediction.shape)
     self.assertEqual((2, ), softmax.shape)
     self.assertTrue(
         0 == prediction[0] or 1 == prediction[0],
         "Prediction must be index 0 or 1, but was {0}".format(
             prediction[0]),
     )
     self.assertAlmostEqual(0.4, softmax[0])
     self.assertEqual(2, prediction[1])
     self.assertAlmostEqual(0.7, softmax[1])
Exemplo n.º 4
0
 def test_happy_path_single(self):
     softmax_values = np.array([0.1, 0.8, 0.08, 0.02])
     softmax_values = np.expand_dims(softmax_values, 0)
     prediction, softmax = MaxSoftmax.calculate(softmax_values)
     self.assertEqual(1, prediction[0])
     self.assertAlmostEqual(0.8, softmax[0])
Exemplo n.º 5
0
 def test_problem_type(self):
     self.assertEqual(MaxSoftmax.problem_type(), ProblemType.CLASSIFICATION)
Exemplo n.º 6
0
 def test_samples_type_declaration(self):
     self.assertFalse(MaxSoftmax.takes_samples())
Exemplo n.º 7
0
 def test_is_confidence(self):
     self.assertTrue(MaxSoftmax.is_confidence())
     self.assertTrue(MaxSoftmax().is_confidence())