我正在使用以下python代码计算损失。
def dice_coefficient(y_true, y_pred, smooth=1.):
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f)
return (2. * intersection + smooth) / (K.sum(y_true_f) + K.sum(y_pred_f) + smooth)
def dice_coefficient_loss(y_true, y_pred):
return -dice_coefficient(y_true, y_pred)
model.compile(
optimizer=opt,
loss=dice_coefficient_loss,
metrics=[dice_coefficient],
)
我的模型以此结束一个时代
488/487 [=============================]-823秒2秒/步-损失: -0.9217-骰子系数:0.9217-val_loss:-0.9367-val_dice_coefficient:0.8289
为什么val_loss和val_dice_coefficient不同,哪一个是正确的?我认为0.8289是正确的,但是为什么在所有时期评估损失都存在差异。
我通过培训一改变了验证生成器,但两者之间还是有区别的。我正在使用Adam,我的模型是3dunet。我有批处理规范。我不使用正则化也没有辍学