评价分割效果好坏的指标
使用:dice=loss_fns.dice_coeff(out,y)
# dice系数:评判分割效果好坏
def dice_coeff(pred, target):
smooth = 1.
num = pred.size(0)
m1 = pred.view(num, -1) # Flatten
m2 = target.view(num, -1) # Flatten
intersection = (m1 * m2).sum()# m1与m2的交集
return (2. * intersection + smooth) / (m1.sum() + m2.sum() + smooth)