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, 0, 1], [0, 0, 1, 0]]
expected_precision = 0.5
with self.test_session():
_, precision = metrics.streaming_sparse_precision_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_precision, precision.eval())
评论列表
文章目录