tensorflow / similarity

TensorFlow Similarity is a python package focused on making similarity learning quick and easy.
Apache License 2.0
1.01k stars 104 forks source link

Addition of siamese Contrastive loss function #248

Open arcAman07 opened 2 years ago

arcAman07 commented 2 years ago

Addition of New Contastive Loss function which is used as a primary metric to calculate loss in siamese networks. If it needs to be added, I would love to work on the PR. Reference : http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf

owenvallis commented 2 years ago

Thanks for offering to work on the PR! This loss is a little older and it comes before Triplet-Loss and the more recent variations on other metric losses. What would you see as the primary use case for the loss, e.g., providing a baseline for benchmarking or does this loss outperform other losses on certain problems?

arcAman07 commented 2 years ago

Personally haven't benchmarked the triplet loss and siamese contrastive loss functions for different datasets, but personally siamese contrastive loss function has always yielded me good results in all my projects where I am training siamese networks. It is also a pretty popular function in the ML community as it an add-on on keras and a PR for its inclusion is on its way even in pytorch. I am of the opinion as this research paper is so important, along with this loss function does yield amazing results ( it also offers diversity in loss functions ), it will be a good addition to this library.

owenvallis commented 2 years ago

Sounds good, thanks. Let's add the PR to the development branch and then we can merge it in to master along with the other recent updates.

arcAman07 commented 2 years ago

Great would start working pn the PR right away 👍