Exemplo n.º 1
0
 def test_binary_cross_entropy(self):
     x = np.arange(-160, 160, 40)
     expected1 = [0., 0., 0., 0., 0.6931471805599453, 40., 80., 120.]
     actual1 = binary_cross_entropy(x, 0).tolist()
     self.assertEqual(expected1, actual1)
     expected2 = [160., 120., 80., 40., 0.6931471805599453, 0., 0., 0.]
     actual2 = binary_cross_entropy(x, 1).tolist()
     self.assertEqual(expected2, actual2)
Exemplo n.º 2
0
 def test_binary_cross_entropy(self):
     x = np.arange(-160, 160, 40)
     expected1 = [0., 0., 0., 0., 0.6931471805599453, 40., 80., 120.]
     actual1 = binary_cross_entropy(x, 0).tolist()
     self.assertEqual(expected1, actual1)
     expected2 = [160., 120., 80., 40., 0.6931471805599453, 0., 0., 0.]
     actual2 = binary_cross_entropy(x, 1).tolist()
     self.assertEqual(expected2, actual2)
     expected3 = 7.686442000846165
     actual3 = binary_cross_entropy(sigmoid(x), 0).sum(0).tolist()
     self.assertEqual(expected3, actual3)
Exemplo n.º 3
0
 def loss(self, graph, vertex_size, label, step_size=2):
     s = self.forward(graph, vertex_size, step_size)
     loss = binary_cross_entropy(s, label)
     return loss