ContrastiveSeg
ContrastiveSeg copied to clipboard
maybe bug in ./segmentor/trainer_contrastive.py
In./segmentor/trainer_contrastive.py I think #138 pixel_queue_ptr[lb] = (pixel_queue_ptr[lb] + 1) % self.memory_size should be #138 pixel_queue_ptr[lb] = (pixel_queue_ptr[lb] + K) % self.memory_size
Hi, @eraserNut thanks for pointing this out. Yes, this is indeed a bug as mentioned in another issue. I will fix this.
In ContrastiveSeg/lib/loss/loss_contrast_mem.py #134
logits_mask = torch.ones_like(mask).scatter_(1, torch.arange(anchor_num * anchor_count).view(-1, 1).cuda(), 0) mask = mask * logits_mask
Can you tell me what the logits_mask does? Can I delete it? Because in my experiments, the logits_mask seems strange in the process.
Hi @eraserNut, please refer to #16. The logits_mask helps to mask out self-similarity of each feature itself.
Hi @eraserNut, please refer to #16. The logits_mask helps to mask out self-similarity of each feature itself.
Thanks for your time. I didn't quite understand why there will be self-similarity pixels. All the anchor pixels are sampled from the training batch, and the contrasive pixels are sampled from the queue. Why multiply of these two kinds of pixels will have self-similarity?
Hi @eraserNut, please refer to #16. The logits_mask helps to mask out self-similarity of each feature itself.
Thanks for your time. I didn't quite understand why there will be self-similarity pixels. All the anchor pixels are sampled from the training batch, and the contrasive pixels are sampled from the queue. Why multiply of these two kinds of pixels will have self-similarity?
I think self-contrastive only exists when queue is None. When queue is not None, logits_mask should not be multiplied to mask, maybe its a unfixed bug.