Skip to content

Instantly share code, notes, and snippets.

View eva-n27's full-sized avatar
💭
I may be slow to respond.

CH3CH3 eva-n27

💭
I may be slow to respond.
View GitHub Profile
@Jerrynet
Jerrynet / contrastive_loss.py
Last active May 11, 2021 14:39
Tensorflow contrastive loss (Numeric stable)
# Contrastive Loss
# by Che-Wei Lin
# Under the Simplified BSD License
import tensorflow as tf
from tensorflow.python.framework.function import Defun
def contrastive_loss(margin, threshold=1e-5):
"""Contrastive loss: