Skip to content

Instantly share code, notes, and snippets.

@doleron
Last active April 8, 2023 20:43
Show Gist options
  • Save doleron/a60f53e06051a9a6ae8f4900c85dab53 to your computer and use it in GitHub Desktop.
Save doleron/a60f53e06051a9a6ae8f4900c85dab53 to your computer and use it in GitHub Desktop.
from tensorflow.keras import backend as K
def euclidean_distance(x, y):
sum_square = K.sum(K.square(x - y), axis=1, keepdims=True)
return K.sqrt(K.maximum(sum_square, K.epsilon()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment