ViT-Adapter icon indicating copy to clipboard operation
ViT-Adapter copied to clipboard

About num_classes for binary semantic segmentation in loss config

Open gjustin40 opened this issue 1 year ago • 1 comments

I'm still working for binary semantic segmentation that has two classes(background:0 / foreground:1 == building)

I have some questions about config of loss.

num_classes=2

        loss_cls=dict(
            type='CrossEntropyLoss',
            use_sigmoid=False,
            loss_weight=2.0,
            reduction='mean',
            class_weight=[1.0] * num_classes + [0.1]),
        loss_mask=dict(
            type='CrossEntropyLoss',
            use_sigmoid=True,
            reduction='mean',
            loss_weight=5.0),
        loss_dice=dict(
            type='DiceLoss',
            use_sigmoid=True,
            activate=True,
            reduction='mean',
            naive_dice=True,
            eps=1.0,
            loss_weight=5.0)
  1. Should i use use_sigmoid= in loss_cls to True if binary segmentation?
  2. In loss_cls, why 'class_weight' has one more class? [1.0]*num_class and extra [0.1]

Thanks

gjustin40 avatar Apr 19 '23 02:04 gjustin40

I also meet the same problem. Have you successfully trained on the binary semantic segmentation? @gjustin40

XinzheGeng avatar Oct 24 '23 02:10 XinzheGeng