info-nce-pytorch icon indicating copy to clipboard operation
info-nce-pytorch copied to clipboard

multiple positive sampels per query

Open YiJun-Yang opened this issue 2 years ago • 1 comments

Hi, Thanks very much for your work. I wonder how should I modify your loss to adapting to the case of multiple positive samples per query. For example, query.shape = (1,128), positive_keys.shape = (5, 128), negative_keys.shape = (5, 128).

Hope your reply

YiJun-Yang avatar Apr 29 '22 13:04 YiJun-Yang

You can look into this paper: Improving Event Representation via Simultaneous Weakly Supervised Contrastive Learning and Clustering They have used multiple positives, in short, what they have done is to call infoNCE for each positive with the same negative samples and got the average of them.

dipta007 avatar Jul 10 '22 01:07 dipta007

@YiJun-Yang I just got similar questions. I post my implementations and understandings in the open issue. If you still have a question about it, you can discuss it with me in the open issue!

Yuntian9708 avatar Jul 03 '23 13:07 Yuntian9708

@YiJun-Yang I just got similar questions. I post my implementations and understandings in the open issue. If you still have a question about it, you can discuss it with me in the open issue!

Have you achieved multiple positive sampels per query?

rainhu22 avatar Jul 05 '23 07:07 rainhu22

@YiJun-Yang I just got similar questions. I post my implementations and understandings in the open issue. If you still have a question about it, you can discuss it with me in the open issue!

Have you achieved multiple positive sampels per query?

my approach is to let one query calculate similarities with each positive sample and then calculate the average value. I think the meaning of this is to make the query similar to the entire positive sample set.

Yuntian9708 avatar Jul 05 '23 07:07 Yuntian9708