msight-tech / research-ms-loss

MS-Loss: Multi-Similarity Loss for Deep Metric Learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_prepare_batch function in RandomIdentitySampler select just positive pair if available!!

torki-hossein opened this issue · comments

Hi,
I read your good paper with title "Multi-similarity loss with general pair weighting for deep metric learning" and based on the content of that paper, I cannot understand logic of "_prepare_batch" function in "RandomIdentitySampler", because you select just positive pair in it (if available).
This make your method bad training!
for convenient i copy mentioned part bellow:
for label in self.labels:
idxs = copy.deepcopy(self.label_index_dict[label])
#load all data indexes that equal to label to idxs
if len(idxs) < self.K:
idxs.extend(np.random.choice(idxs, size=self.K - len(idxs), replace=True))

Ok, For future usage this is a short answer wrote in MS-Loss paper:
For every mini-batch, we randomly choose a certain
number of classes, and then randomly sample M instances
from each class with M = 5 for all datasets in all experiments.