예제 #1
0
 def testTop2(self):
   top_2_fn = eval_metrics._top_k_generator(2)
   probabilities = constant_op.constant([[0.1, 0.2, 0.3], [0.4, 0.7, 0.5],
                                         [0.9, 0.8, 0.2], [0.6, 0.4, 0.8]])
   targets = constant_op.constant([[0], [2], [1], [1]])
   in_top_2_op, update_op = top_2_fn(probabilities, targets)
   with self.test_session():
     # initializes internal accuracy vars
     variables.local_variables_initializer().run()
     # need to call in order to run the in_top_2_op internal operations because
     # it is a streaming function
     update_op.eval()
     self.assertNear(0.5, in_top_2_op.eval(), 0.0001)
 def testTop2(self):
   top_2_fn = eval_metrics._top_k_generator(2)
   probabilities = constant_op.constant([[0.1, 0.2, 0.3], [0.4, 0.7, 0.5],
                                         [0.9, 0.8, 0.2], [0.6, 0.4, 0.8]])
   targets = constant_op.constant([[0], [2], [1], [1]])
   in_top_2_op, update_op = top_2_fn(probabilities, targets)
   with self.test_session():
     # initializes internal accuracy vars
     variables.local_variables_initializer().run()
     # need to call in order to run the in_top_2_op internal operations because
     # it is a streaming function
     update_op.eval()
     self.assertNear(0.5, in_top_2_op.eval(), 0.0001)