salesforce/PCL

are something wrong in the builder of PCL?

ZhiyuanDang opened this issue · 5 comments

labels_proto = torch.linspace(0, q.size(0)-1, steps=q.size(0)).long().cuda()

After carefully reviewing the code, I think the torch.linspace in the above line should be torch.zeros since the positive prototypes have been concatenated the first dim.

Hi, thanks for your interest!

pos_prototypes have a size of B x low_dim, thus in logits_proto, for the first B x B elements, the diagonals correspond to positive logits. note that each prototype in pos_prototypes are considered negative prototypes for other samples in the mini-batch.

have a size of B x low_dim

may I ask, if two data points in same mini-batch belonged to same pos_prototypes, they will still be considered as negative prototypes?

Hi, the negatives are selected in a way that exclude all positives in the mini-batch.

Hi, the negatives are selected in a way that exclude all positives in the mini-batch.

Yes, I mean for two data points in one mini-batch, if they belong to same prototype, in the loss calculation for one data point, the other will be considered as negative prototype right? since the prototype label is torch.linspace(0, q.size(0)-1, steps=q.size(0)).long().cuda() , which only consider itself.

Yes you are right. The chance of this happening is very low, though, given the large number of prototypes compared to batch size. Thanks!