Beispiel #1
0
 def testGetInstanceEmbeddingLossBatch(self):
     embedding1 = self.get_embedding1()
     embedding1 = tf.stack([embedding1, embedding1, embedding1])
     embedding2 = self.get_embedding2()
     embedding2 = tf.stack([embedding2, embedding2, embedding2])
     labels = self.get_labels1()
     labels = tf.stack([labels, labels, labels])
     l11 = mll.get_instance_embedding_loss(embedding1, 'npair', labels, 100,
                                           100, 10)
     l12 = mll.get_instance_embedding_loss(embedding2, 'npair', labels, 100,
                                           100, 10)
     l21 = mll.get_instance_embedding_loss(embedding1, 'npair_r_c', labels,
                                           10, 100, 10)
     l22 = mll.get_instance_embedding_loss(embedding2, 'npair_r_c', labels,
                                           10, 100, 10)
     l31 = mll.get_instance_embedding_loss(embedding1, 'npair_r_c_r_s',
                                           labels, 10, 100, 10)
     l32 = mll.get_instance_embedding_loss(embedding2, 'npair_r_c_r_s',
                                           labels, 10, 100, 10)
     l41 = mll.get_instance_embedding_loss(embedding1, 'npair_r_s', labels,
                                           10, 100, 10)
     l42 = mll.get_instance_embedding_loss(embedding2, 'npair_r_s', labels,
                                           10, 100, 10)
     l51 = mll.get_instance_embedding_loss(embedding1, 'iou', labels, 10,
                                           100, 10)
     l52 = mll.get_instance_embedding_loss(embedding2, 'iou', labels, 10,
                                           100, 10)
     self.assertLess(l11.numpy(), l12.numpy())
     self.assertLess(l21.numpy(), l22.numpy())
     self.assertLess(l31.numpy(), l32.numpy())
     self.assertLess(l41.numpy(), l42.numpy())
     self.assertLess(l51.numpy(), l52.numpy())
Beispiel #2
0
 def test_get_instance_embedding_loss(self):
     embedding1 = self.get_embedding1()
     embedding2 = self.get_embedding2()
     labels = self.get_labels1()
     l11 = mll.get_instance_embedding_loss(embedding1, 'npair', labels, 100,
                                           100, 10)
     l12 = mll.get_instance_embedding_loss(embedding2, 'npair', labels, 100,
                                           100, 10)
     l21 = mll.get_instance_embedding_loss(embedding1, 'npair_r_c', labels,
                                           10, 100, 10)
     l22 = mll.get_instance_embedding_loss(embedding2, 'npair_r_c', labels,
                                           10, 100, 10)
     l31 = mll.get_instance_embedding_loss(embedding1, 'npair_r_c_r_s',
                                           labels, 10, 100, 10)
     l32 = mll.get_instance_embedding_loss(embedding2, 'npair_r_c_r_s',
                                           labels, 10, 100, 10)
     l41 = mll.get_instance_embedding_loss(embedding1, 'npair_r_s', labels,
                                           10, 100, 10)
     l42 = mll.get_instance_embedding_loss(embedding2, 'npair_r_s', labels,
                                           10, 100, 10)
     l51 = mll.get_instance_embedding_loss(embedding1, 'iou', labels, 10,
                                           100, 10)
     l52 = mll.get_instance_embedding_loss(embedding2, 'iou', labels, 10,
                                           100, 10)
     self.assertLess(l11.numpy(), l12.numpy())
     self.assertLess(l21.numpy(), l22.numpy())
     self.assertLess(l31.numpy(), l32.numpy())
     self.assertLess(l41.numpy(), l42.numpy())
     self.assertLess(l51.numpy(), l52.numpy())