metric_ops_test.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:lsdc 作者: febert 项目源码 文件源码
def testWeighted2d(self):
    predictions_values = [0.1, 0.2, 0.4, 0.3, 0.0,
                          0.1, 0.2, 0.2, 0.26, 0.26]
    labels_values = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
    weights_values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

    predictions = tf.constant(predictions_values, dtype=tf.float32)
    labels = tf.constant(labels_values)
    weights = tf.constant(weights_values)
    specificity, update_op = metrics.streaming_specificity_at_sensitivity(
        predictions, labels, weights=weights, sensitivity=0.4)

    with self.test_session() as sess:
      sess.run(tf.initialize_local_variables())

      self.assertAlmostEqual(8.0 / 15.0, sess.run(update_op))
      self.assertAlmostEqual(8.0 / 15.0, specificity.eval())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号