VNET 骰子损失大于 1

VNET Dice loss higher than 1

我正在使用 Keras 2.2.4 和 Tensorflow 1.12.0 训练 Vnet 解决分段问题(我无法更改 TensorFlow 版本)。掩码,即 y_true,是 (1,200,150,100,2) 数组。我想最小化定义为的骰子损失:

'''

def dice_loss_foreground(y_true, y_pred):

    elements_per_class=tf.math.reduce_sum(y_true[:,:,:,:,1])
    predicted_per_class=tf.math.reduce_sum(y_pred[:,:,:,:,1])
    intersection=tf.math.scalar_mul(2.0,tf.math.reduce_sum(tf.math.multiply(y_pred[:,:,:,:,1],y_true[:,:,:,:,1])))
    union=elements_per_class+predicted_per_class
    acc=intersection/(union+0.0001)
    return 1.0-acc

'''

我已经在模拟示例上测试了这个定义,它从 0 变为 1,但是在训练过程中,损失达到了大于 1 的数字。任何人都可以帮助我理解为什么吗?谢谢!

损失函数不仅仅是由骰子定义的,它还包含正则化。因此,即使 dice coefficient loss 应该在 0-1 范围内,它也可能大于 1,具体取决于正则化。