Instructions to use keras-io/siamese-contrastive with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TF-Keras
How to use keras-io/siamese-contrastive with TF-Keras:
# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy) # See https://github.com/keras-team/tf-keras for more details. from huggingface_hub import from_pretrained_keras model = from_pretrained_keras("keras-io/siamese-contrastive") - Notebooks
- Google Colab
- Kaggle
Confusion on the Contrastive Loss
#2
by gkmeng - opened
Hi, thank you for the interesting application. However I have some questions regarding the way keras-io do the labelling and the eqn of contrastive loss.
In the original pair, similar pairs are assigned as 0 and dissimilar pairs are assigned as 1, and the equation used are as follows:
loss = [(1 - y ) x D] + [(y) X max(margin-D, 0)]
However in the example given by Keras (https://keras.io/examples/vision/siamese_contrastive/), the labelling method are reversed, and the same equation of contrastive loss are still used. Any reason why keras did so? Thank you.