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())
评论列表
文章目录