在培训和验证过程中,我一直试图以二进制交叉熵作为损失,并阅读dice_coeff和iou作为衡量标准。经过5个年代后的结果是
Epoch 5/5 2373/2373 [==============================] - 84s 35ms/step - loss: 0.0260 - dice_coef: 0.9864 - iou: 0.9734 - val_loss: 0.0579 - val_dice_coef: 0.9583 - val_iou: 0.9216
我使用的指标如下:
def iou(y_true, y_pred):
def f(y_true, y_pred):
intersection = (y_true * y_pred).sum()
union = y_true.sum() + y_pred.sum() - intersection
x = (intersection + 1e-15) / (union + 1e-15)
x = x.astype(np.float32)
return x
return tf.numpy_function(f, [y_true, y_pred], tf.float32)
smooth = 1e-15
def dice_coef(y_true, y_pred):
y_true = tf.keras.layers.Flatten()(y_true)
y_pred = tf.keras.layers.Flatten()(y_pred)
intersection = tf.reduce_sum(y_true * y_pred)
return (2. * intersection + smooth) / (tf.reduce_sum(y_true) + tf.reduce_sum(y_pred) + smooth)
def dice_loss(y_true, y_pred):
return 1.0 - dice_coef(y_true, y_pred)
评估结果在这里
46/46 [==============================] - 12s 259ms/step - loss: 0.0557 - dice_coef: 0.9567 - iou: 0.9181
,我怀疑这是
发布于 2021-05-29 21:49:08
如果要将阈值考虑在内,则需要绘制ROC曲线。对于二进制分类(每像素),ROC曲线向您展示了准确度和特异性随阈值的变化。
一旦你有了一条ROC曲线,你就可以测量“曲线下面积”,得到一个计算分类器的数字。
您可以使用sklearn.metrics.roc_curve
实现来计算它。
https://stackoverflow.com/questions/67757876
复制相似问题