ContrastiveSeg icon indicating copy to clipboard operation
ContrastiveSeg copied to clipboard

maybe bug in ./segmentor/trainer_contrastive.py

Open eraserNut opened this issue 1 year ago • 5 comments

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

eraserNut avatar Aug 31 '22 14:08 eraserNut

Hi, @eraserNut thanks for pointing this out. Yes, this is indeed a bug as mentioned in another issue. I will fix this.

tfzhou avatar Sep 01 '22 07:09 tfzhou

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.

eraserNut avatar Sep 07 '22 03:09 eraserNut

Hi @eraserNut, please refer to #16. The logits_mask helps to mask out self-similarity of each feature itself.

tfzhou avatar Sep 08 '22 12:09 tfzhou

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?

weiaicunzai avatar Feb 27 '23 13:02 weiaicunzai

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.

crisz94 avatar May 08 '24 06:05 crisz94