【问题标题】:Correct way to reduce dimension in dice loss减少骰子损失的正确方法
【发布时间】: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


    【解决方案1】:

    这取决于不同维度的含义。
    如果您的通道维度意味着不同类别的分割掩码(又名"semantic segmentation"),那么计算每个通道的 Dice,然后对通道和批次进行平均将为您提供每个类别的平均 Dice。
    或者,如果你也计算通道上的骰子(第二个选项),你有一个多类骰子(我不确定这是否是一个“东西”)并且你报告它在批次中的平均值。

    你想计算什么?

    【讨论】:

      猜你喜欢
      • 2020-05-05
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      • 2017-09-15
      • 2020-03-15
      • 1970-01-01
      • 1970-01-01
      • 2021-04-21
      相关资源
      最近更新 更多