metric_ops_test.py 文件源码

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

项目:lsdc 作者: febert 项目源码 文件源码
def testResultsWithSomeMissing(self):
    predictions = tf.concat(0, [tf.constant(0, shape=[5]),
                                tf.constant(1, shape=[5])])
    labels = tf.concat(0, [tf.constant(0, shape=[3]),
                           tf.constant(1, shape=[7])])
    num_classes = 2
    mask = tf.concat(0, [tf.constant(False, shape=[9]),
                         tf.constant(True, shape=[1])])
    weights = tf.concat(0, [tf.constant(0, shape=[1]),
                            tf.constant(1, shape=[9])])
    with self.test_session() as sess:
      miou, update_op = metrics.streaming_mean_iou(
          predictions, labels, num_classes, ignore_mask=mask, weights=weights)
      sess.run(tf.initialize_local_variables())
      self.assertAllEqual([[2, 2], [0, 4]], update_op.eval())
      desired_miou = np.mean([2./4., 4./6.])
      self.assertAlmostEqual(desired_miou, miou.eval())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号