【发布时间】:2021-09-30 23:55:45
【问题描述】:
我很困惑如何减少用于分割的骰子损失函数中的维度。
这是输入形状(B,C,H,W)
有两种方法可以减少
先求空间维数,再取batch和channels的均值
reduce_axis=[2,3]
denominator = torch.sum(true, dim=reduce_axis) + torch.sum(pred, dim=reduce_axis)
dice=1.0 - (2.0 * intersection + smooth) / (denominator + smooth)
torch.mean(dice) # the batch and channel average
先对所有维度求和,批次除外,然后是平均批次
reduce_axis=[1,2,3]
denominator = torch.sum(true, dim=reduce_axis) + torch.sum(pred, dim=reduce_axis)
dice=1.0 - (2.0 * intersection + smooth) / (denominator + smooth)
torch.mean(dice) # the batch and channel average
【问题讨论】:
标签: python deep-learning pytorch image-segmentation semantic-segmentation