ZwwWayne / K-Net

[NeurIPS2021] Code Release of K-Net: Towards Unified Image Segmentation
Apache License 2.0
467 stars 45 forks source link

对loss的一些疑问 #13

Closed talebolano closed 2 years ago

talebolano commented 2 years ago

Hi,我对kernel_update_head.py中label_weights的实现有一些疑问。在kernel_update_head.py中_get_target_single函数中,将为何要将sem_thing_weights在 num_thing_classes上的权重设为0,将其设为1使sem label将thing 的类别视为负样本不是更符合常理的做法么,同理label_weights在num_stuff_classes的权重也设为0也不是很能理解。可以解释下这样做带来的好处么?

            sem_stuff_weights = torch.eye(
                self.num_stuff_classes, device=pos_mask.device)
            sem_thing_weights = pos_mask.new_zeros(
                (self.num_stuff_classes, self.num_thing_classes))
            sem_label_weights = torch.cat(
                [sem_thing_weights, sem_stuff_weights], dim=-1)
......
            label_weights[:, self.num_thing_classes:] = 0
ZwwWayne commented 2 years ago

This makes the semantic kernels learn to only predict whether it belongs to its corresponding semantic class without the influence of other classes.