tensorflow 里metrics_tensorflow - 如何在Tensorflow中正确使用tf.metrics.mean_iou在Tensorboard上显示混淆矩阵? - 堆栈内存溢出...

在TensorFlow中使用tf.metrics.mean_iou计算iou,并在TensorBoard上显示混淆矩阵。通过获取'mean_iou/total_confusion_matrix:0'张量,计算精度和召回率矩阵。使用tf.print在终端输出,同时用tf.summary.text在TensorBoard展示精度和召回率矩阵。
摘要由CSDN通过智能技术生成

由于有人投票,我将在这里发布我的答案。

假设您以以下方式定义了mean_iou op:

miou, update_op = tf.metrics.mean_iou(

predictions, labels, dataset.num_of_classes, weights=weights)

tf.summary.scalar(predictions_tag, miou)

如果在Tensorboard中看到图形,则会发现有一个名为“ mean_iou”的节点,并且在扩展此节点后,您会发现有一个名为“ total_confucion_matrix”的操作。 这是您计算每个类别的查全率和查准率所需要的。

aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS95aVhCbi5wbmc=

获得节点名称后,可以通过tf.summary.text将其添加到张量tf.summary.text或者通过tf.print函数在终端中进行打印。 下面是一个示例:

miou, update_op = tf.metrics.mean_iou(

predictions, labels, dataset.num_of_classes, weights=weights)

tf.summary.scalar(predictions_tag, miou)

# Get the correct tensor name of confusion matrix, different graphs may vary

confusion_matrix =

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值