Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add double-margin contrastive loss layer #4476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonbakerfish
Copy link

Migrate and reimplement the double-margin contrastive loss from https://bitbucket.org/jonbakerfish/caffe. For consistency (see #2308), this implementation is slightly different from the above repo.
The bitbucket one implements the loss in the following form:
L = y * max(d^2 - margin1, 0) + (1-y) * max(margin2 - d^2, 0)
whereas this PR implements:
L = y * max(d - margin1, 0)^2 + (1-y) * max(margin2 - d, 0)^2

This loss has been used in the following works:
[1] Lin et al. DeepHash: Getting Regularization, Depth and Fine-Tuning Right. CoRR, 2015
[2] Sadeghi et al. VISALOGY: Answering Visual Analogy Questions. In NIPS, 2015.
[3] Cao et al. Quartet-net Learning for Visual Instance Retrieval. In MM, 2016.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant