def testUpdateOpEvalIsAccumulatedConfusionMatrix(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
with self.test_session() as sess:
miou, update_op = metrics.streaming_mean_iou(
predictions, labels, num_classes)
sess.run(tf.initialize_local_variables())
confusion_matrix = update_op.eval()
self.assertAllEqual([[3, 2], [0, 5]], confusion_matrix)
desired_miou = np.mean([3./5., 5./7.])
self.assertAlmostEqual(desired_miou, miou.eval())
评论列表
文章目录