def test_sparse_tensor_value(self):
predictions = [[0.1, 0.3, 0.2, 0.4], [0.1, 0.2, 0.3, 0.4]]
labels = [[0, 0, 1, 0], [0, 0, 0, 1]]
expected_recall = 0.5
with self.test_session():
_, recall = metrics.streaming_sparse_recall_at_k(
predictions=tf.constant(predictions, tf.float32),
labels=_binary_2d_label_to_sparse_value(labels), k=1)
tf.initialize_variables(tf.local_variables()).run()
self.assertEqual(expected_recall, recall.eval())
评论列表
文章目录