Towards Data Science, Artificial Intelligence, TensorFlow, Machine Learning, Deep Learning.
term, so the max term dominates the calculation of the loss. Contrastive Loss using Wrapper Function def contrastive_loss_with_margin(margin): def contrastive_loss(y_true, y_pred): square_pred = K.square(y_pred) margin_square = K.square(K.maximum(margin - y_pred, 0)) return K.mean(y_true *