Created
April 9, 2023 01:25
-
-
Save doleron/fa03e8112cbed32dc8875348bb527024 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def contrastive_loss_with_margin(margin=1): | |
def contrastive_loss(y_true, y_pred): | |
square_pred = K.square(y_pred) | |
margin_square = K.square(K.maximum(margin - y_pred, 0)) | |
return (y_true * square_pred + (1 - y_true) * margin_square) | |
return contrastive_loss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment