Skip to content

Implement the triplet ranking hinge loss layer#603

Closed
kloudkl wants to merge 1 commit intoBVLC:devfrom
kloudkl:triplet-ranking-hinge-loss
Closed

Implement the triplet ranking hinge loss layer#603
kloudkl wants to merge 1 commit intoBVLC:devfrom
kloudkl:triplet-ranking-hinge-loss

Conversation

@kloudkl
Copy link
Contributor

@kloudkl kloudkl commented Jul 3, 2014

The triplet ranking hinge loss plays an important role in the deep ranking network of Google (#578). The major reference for the loss function is [1].

Compared with the Weighted Approximate Rank Pairwise (WARP) loss layer (#257, #126, #88), this loss is much simpler.

[1] Mohammad Norouzi, David Fleet, and Ruslan Salakhutdinov. Hamming Distance Metric Learning. NIPS 2013.

@jay2002
Copy link

jay2002 commented Aug 8, 2014

is the gradient correct?
I'm not sure about how to compute the gradient :(, I think the L2 gradient is:
caffe_scal(count, Dtype(2. / num), similar_sample_diff);
caffe_scal(count, Dtype(-2. / num), dissimilar_sample_diff);

@kloudkl
Copy link
Contributor Author

kloudkl commented Aug 8, 2014

How did you derive the formula?

@jay2002
Copy link

jay2002 commented Aug 8, 2014

the formula is
1 + L2(query, similar) - L2(query, dissimilar)
So I just thought the diff is like euclidean loss,
(query - similar) - (query - dissimilar)

@jay2002
Copy link

jay2002 commented Aug 8, 2014

In that paper, is the ranking model need to train three different convnet model (Q, P, N) at the same time? If it is, how to get the final feature after optimized?

@kloudkl
Copy link
Contributor Author

kloudkl commented Aug 9, 2014

The feature triplets <Query feature, Similar sample feature, Dissimilar sample feature> should be generated by the same model. Otherwise, the distances between them are not comparable.

@kkcaros
Copy link

kkcaros commented Oct 8, 2014

Sorry , I am so new to caffe ,Can you give a simple example that how to use the triplet ranking hinge loss in the train.prototxt and val.prototxt;

@kloudkl
Copy link
Contributor Author

kloudkl commented Oct 13, 2014

@kkcaros, please refer to the tutorial Siamese Network Training with Caffe.

@windyting0331
Copy link

hi, I have read the code of the test cases for triple ranking loss and found that it checks the gradient of (*bottom)[0] ,but bottom[0] is the cpu diff of query data. In the backward function, you do not compute the diff of query data, so it may be always 0. Is there anything wrong?

@shelhamer
Copy link
Member

Closed as abandoned -- feel free to rescue if interested since a ranking loss could be useful.

@shelhamer shelhamer closed this Mar 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments