luhaofang / tripletloss

tripletloss in caffe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tripletselectlayer possible bug?

TuBui opened this issue · comments

commented

Hi, thanks for the code.
In tripletselectlayer.py line 71-73:

bottom[0].diff[self.tripletlist[i][0]] = top[0].diff[i]
bottom[0].diff[self.tripletlist[i][1]] = top[1].diff[i]
bottom[0].diff[self.tripletlist[i][2]] = top[2].diff[i]

Since an image can be selected twice in self.tripletlist (e.g. [[0,10,100], [1,100,8]...] here image id 100 appears as the hard negative sample for anchor 0, but hard positive sample for anchor 1), I suggest changing to code line 71-73 to:

bottom[0].diff[self.tripletlist[i][0]] += top[0].diff[i]
bottom[0].diff[self.tripletlist[i][1]] += top[1].diff[i]
bottom[0].diff[self.tripletlist[i][2]] += top[2].diff[i]

Do u agree?

@TuBui Hi,thanks for your correction, I think you are right.