-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem in contrastive loss #16
Comments
Same question here. Can anyone explain why the masks and logits are formed like this? |
why we use logits_mask = torch.ones_like(mask).scatter_(1, |
I think the purpose is to ignore the similarity of the feature itself. |
Same question here, could you help explain why the masks and logits are formed like this? @tfzhou |
Hmmm, but when "queue" is not None, "contrast_feature" is from "queue" and "anchor_feature" is from "X_anchor", so I think they are totally different and there is no need to ignore the feature itself. |
I have another question about function
If |
I finally find partners here,I have a question. |
Thanks for the questions! @Jarvis73 L134-138 is to remove self-contrastive. @Xxxxiahaofeng, the purpose to remove |
I agree with your opinion. I think |
hi @tfzhou , I think self-contrastive only exists when queue==None. |
Hi, Dr. Zhou,
Thanks for releasing the code. When reading the code about the contrastive loss in function
_contrastive()
, amask
is computed by following two lines:ContrastiveSeg/lib/loss/loss_contrast_mem.py
Line 124 in 2ab84d8
and
ContrastiveSeg/lib/loss/loss_contrast_mem.py
Line 131 in 2ab84d8
Now I think the shape of the
mask
is[anchor_num * anchor_count, class_num * cache_size]
. If I did not misunderstand the code, themask
is a 'positive' mask, and each line represents the positive samples of an anchor view.Then in L134-L138, the function of
logits_mask
is confusing:ContrastiveSeg/lib/loss/loss_contrast_mem.py
Lines 134 to 138 in 2ab84d8
Could you please explain these lines?
Suppose I have anchor_num=6 (2 images, 3 valid classes per image), anchor_count=2 (sample two pixels per class), class_num=5 (class number), cache_size=2 (memory size), then the following code raises RuntimeError:
Output:
The text was updated successfully, but these errors were encountered: