【发布时间】:2018-04-08 06:39:24
【问题描述】:
tensorflow.metrics.mean_iou() 当前是每个类的 iou 的平均值。我想为我的二元语义分割问题获得仅前景的iou。
我尝试将weights 用作tf.constant([0.0, 1.0]),但tf.constant([0.01, 0.99]) 但mean_iou 看起来仍然溢出,如下所示:
(500, 1024, 1024, 1)
119/5000 [..............................] - ETA: 4536s - loss: 0.3897 - mean_iou: -789716217654962048.0000 - acc: 0.9335
我将其用作metrics for keras fit_generator,如下所示:
def mean_iou(y_true, y_pred):
y_pred = tf.to_int32(y_pred > 0.5)
score, up_opt = tf.metrics.mean_iou(y_true, y_pred, 2, weights = tf.constant([0.01, 0.99]))
keras.get_session().run(tf.local_variables_initializer())
with tf.control_dependencies([up_opt]):
score = tf.identity(score)
return score
我非常感谢任何帮助,因为我已经尝试了很多事情,甚至只使用 keras.backend 函数自己计算损失,但看起来都不正确。
【问题讨论】:
标签: tensorflow keras image-segmentation